Commit 0b0d4850 authored by DrKLO's avatar DrKLO
parent 69c3c606
...@@ -81,7 +81,7 @@ android { ...@@ -81,7 +81,7 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 8 minSdkVersion 8
targetSdkVersion 19 targetSdkVersion 19
versionCode 258 versionCode 260
versionName "1.5.5" versionName "1.5.6"
} }
} }
...@@ -3,10 +3,10 @@ LOCAL_PATH := $(call my-dir) ...@@ -3,10 +3,10 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_PRELINK_MODULE := false LOCAL_PRELINK_MODULE := false
LOCAL_MODULE := tmessages LOCAL_MODULE := tmessages
LOCAL_CFLAGS := -w -std=gnu99 -O3 -DNULL=0 -DSOCKLEN_T=socklen_t -DLOCALE_NOT_USED -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -DLOG_DISABLED LOCAL_CFLAGS := -w -std=gnu99 -O2 -DNULL=0 -DSOCKLEN_T=socklen_t -DLOCALE_NOT_USED -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 -DLOG_DISABLED
LOCAL_CFLAGS += -Drestrict='' -D__EMX__ -DOPUS_BUILD -DFIXED_POINT -DUSE_ALLOCA -DHAVE_LRINT -DHAVE_LRINTF -fno-math-errno LOCAL_CFLAGS += -Drestrict='' -D__EMX__ -DOPUS_BUILD -DFIXED_POINT -DUSE_ALLOCA -DHAVE_LRINT -DHAVE_LRINTF -fno-math-errno
LOCAL_CFLAGS += -DANDROID_NDK -DDISABLE_IMPORTGL -fno-strict-aliasing -fprefetch-loop-arrays -DAVOID_TABLES -DANDROID_TILE_BASED_DECODE -DANDROID_ARMV6_IDCT LOCAL_CFLAGS += -DANDROID_NDK -DDISABLE_IMPORTGL -fno-strict-aliasing -fprefetch-loop-arrays -DAVOID_TABLES -DANDROID_TILE_BASED_DECODE -DANDROID_ARMV6_IDCT
LOCAL_CPPFLAGS := -DBSD=1 -ffast-math -O3 -funroll-loops LOCAL_CPPFLAGS := -DBSD=1 -ffast-math -O2 -funroll-loops
#LOCAL_LDLIBS := -llog #LOCAL_LDLIBS := -llog
LOCAL_SRC_FILES := \ LOCAL_SRC_FILES := \
......
...@@ -2584,10 +2584,11 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -2584,10 +2584,11 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
public void tcpConnectionConnected(TcpConnection connection) { public void tcpConnectionConnected(TcpConnection connection) {
Datacenter datacenter = datacenterWithId(connection.getDatacenterId()); Datacenter datacenter = datacenterWithId(connection.getDatacenterId());
if (datacenter.authKey != null) { if (datacenter.authKey != null) {
processRequestQueue(connection.transportRequestClass, connection.getDatacenterId());
if ((connection.transportRequestClass & RPCRequest.RPCRequestClassPush) != 0) { if ((connection.transportRequestClass & RPCRequest.RPCRequestClassPush) != 0) {
sendingPushPing = false; sendingPushPing = false;
lastPushPingTime = System.currentTimeMillis() - 60000 * 3 + 10000; lastPushPingTime = System.currentTimeMillis() - 60000 * 3 + 10000;
} else {
processRequestQueue(connection.transportRequestClass, connection.getDatacenterId());
} }
} }
} }
......
...@@ -44,6 +44,7 @@ public class FileLog { ...@@ -44,6 +44,7 @@ public class FileLog {
return; return;
} }
dateFormat = FastDateFormat.getInstance("dd_MM_yyyy_HH_mm_ss", Locale.US); dateFormat = FastDateFormat.getInstance("dd_MM_yyyy_HH_mm_ss", Locale.US);
try {
File sdCard = ApplicationLoader.applicationContext.getExternalFilesDir(null); File sdCard = ApplicationLoader.applicationContext.getExternalFilesDir(null);
if (sdCard == null) { if (sdCard == null) {
return; return;
...@@ -57,6 +58,9 @@ public class FileLog { ...@@ -57,6 +58,9 @@ public class FileLog {
if (currentFile == null) { if (currentFile == null) {
return; return;
} }
} catch (Exception e) {
e.printStackTrace();
}
try { try {
currentFile.createNewFile(); currentFile.createNewFile();
FileOutputStream stream = new FileOutputStream(currentFile); FileOutputStream stream = new FileOutputStream(currentFile);
......
...@@ -12,7 +12,6 @@ import android.app.Activity; ...@@ -12,7 +12,6 @@ import android.app.Activity;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.PowerManager;
import org.json.JSONObject; import org.json.JSONObject;
import org.telegram.ui.ApplicationLoader; import org.telegram.ui.ApplicationLoader;
...@@ -20,7 +19,6 @@ import org.telegram.ui.ApplicationLoader; ...@@ -20,7 +19,6 @@ import org.telegram.ui.ApplicationLoader;
public class GcmBroadcastReceiver extends BroadcastReceiver { public class GcmBroadcastReceiver extends BroadcastReceiver {
public static final int NOTIFICATION_ID = 1; public static final int NOTIFICATION_ID = 1;
private static PowerManager.WakeLock wakeLock = null;
private static final Integer sync = 1; private static final Integer sync = 1;
@Override @Override
...@@ -28,27 +26,6 @@ public class GcmBroadcastReceiver extends BroadcastReceiver { ...@@ -28,27 +26,6 @@ public class GcmBroadcastReceiver extends BroadcastReceiver {
FileLog.d("tmessages", "GCM received intent: " + intent); FileLog.d("tmessages", "GCM received intent: " + intent);
if (intent.getAction().equals("com.google.android.c2dm.intent.RECEIVE")) { if (intent.getAction().equals("com.google.android.c2dm.intent.RECEIVE")) {
synchronized (sync) {
try {
if (wakeLock == null) {
PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "lock");
}
if (!wakeLock.isHeld()) {
wakeLock.acquire(5000);
}
} catch (Exception e) {
try {
if (wakeLock != null) {
wakeLock.release();
}
} catch (Exception e2) {
FileLog.e("tmessages", e2);
}
FileLog.e("tmessages", e);
}
}
Utilities.RunOnUIThread(new Runnable() { Utilities.RunOnUIThread(new Runnable() {
@Override @Override
public void run() { public void run() {
......
...@@ -4452,6 +4452,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter ...@@ -4452,6 +4452,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
boolean needVibrate = false; boolean needVibrate = false;
String choosenSoundPath = null; String choosenSoundPath = null;
int ledColor = 0xff00ff00;
if (chat_id != 0) { if (chat_id != 0) {
choosenSoundPath = preferences.getString("sound_chat_path_" + chat_id, null); choosenSoundPath = preferences.getString("sound_chat_path_" + chat_id, null);
...@@ -4461,6 +4462,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter ...@@ -4461,6 +4462,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
choosenSoundPath = preferences.getString("GroupSoundPath", defaultPath); choosenSoundPath = preferences.getString("GroupSoundPath", defaultPath);
} }
needVibrate = preferences.getBoolean("EnableVibrateGroup", true); needVibrate = preferences.getBoolean("EnableVibrateGroup", true);
ledColor = preferences.getInt("GroupLed", 0xff00ff00);
} else if (user_id != 0) { } else if (user_id != 0) {
choosenSoundPath = preferences.getString("sound_path_" + user_id, null); choosenSoundPath = preferences.getString("sound_path_" + user_id, null);
if (choosenSoundPath != null && choosenSoundPath.equals(defaultPath)) { if (choosenSoundPath != null && choosenSoundPath.equals(defaultPath)) {
...@@ -4469,6 +4471,10 @@ public class MessagesController implements NotificationCenter.NotificationCenter ...@@ -4469,6 +4471,10 @@ public class MessagesController implements NotificationCenter.NotificationCenter
choosenSoundPath = preferences.getString("GlobalSoundPath", defaultPath); choosenSoundPath = preferences.getString("GlobalSoundPath", defaultPath);
} }
needVibrate = preferences.getBoolean("EnableVibrateAll", true); needVibrate = preferences.getBoolean("EnableVibrateAll", true);
ledColor = preferences.getInt("MessagesLed", 0xff00ff00);
}
if (preferences.contains("color_" + dialog_id)) {
ledColor = preferences.getInt("color_" + dialog_id, 0);
} }
if (!needVibrate && vibrate_override == 1) { if (!needVibrate && vibrate_override == 1) {
...@@ -4478,6 +4484,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter ...@@ -4478,6 +4484,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter
} }
String name = Utilities.formatName(user.first_name, user.last_name); String name = Utilities.formatName(user.first_name, user.last_name);
if ((int)dialog_id == 0) {
name = LocaleController.getString("AppName", R.string.AppName);
}
String msgShort = msg.replace(name + ": ", "").replace(name + " ", ""); String msgShort = msg.replace(name + ": ", "").replace(name + " ", "");
intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE); intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE);
...@@ -4511,7 +4520,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter ...@@ -4511,7 +4520,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter
mBuilder.setContentIntent(contentIntent); mBuilder.setContentIntent(contentIntent);
mNotificationManager.cancel(1); mNotificationManager.cancel(1);
Notification notification = mBuilder.build(); Notification notification = mBuilder.build();
notification.ledARGB = 0xff00ff00; if (ledColor != 0) {
notification.ledARGB = ledColor;
}
notification.ledOnMS = 1000; notification.ledOnMS = 1000;
notification.ledOffMS = 1000; notification.ledOffMS = 1000;
if (needVibrate) { if (needVibrate) {
......
...@@ -16,80 +16,20 @@ import java.io.File; ...@@ -16,80 +16,20 @@ import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
public class NativeLoader { public class NativeLoader {
private static final long sizes[] = new long[] { private static final long sizes[] = new long[] {
922256, //armeabi 795280, //armeabi
991908, //armeabi-v7a 844452, //armeabi-v7a
1713204, //x86 1242164, //x86
0, //mips 0, //mips
}; };
private static volatile boolean nativeLoaded = false; private static volatile boolean nativeLoaded = false;
public static void cleanNativeLog(Context context) {
try {
File sdCard = context.getFilesDir();
if (sdCard == null) {
return;
}
File file = new File(sdCard, "nativeer.log");
if (file == null || !file.exists()) {
return;
}
file.delete();
} catch (Exception e) {
e.printStackTrace();
}
}
private static OutputStreamWriter streamWriter = null;
private static FileOutputStream stream = null;
private static void closeStream() {
try {
if (stream != null) {
streamWriter.close();
stream.close();
stream = null;
streamWriter = null;
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static void writeNativeError(Context context, String info, Throwable throwable) {
try {
if (stream == null) {
File sdCard = context.getFilesDir();
if (sdCard == null) {
return;
}
File file = new File(sdCard, "nativeer.log");
if (file == null) {
return;
}
stream = new FileOutputStream(file);
streamWriter = new OutputStreamWriter(stream);
}
streamWriter.write(info + "\n");
streamWriter.write(throwable + "\n");
StackTraceElement[] stack = throwable.getStackTrace();
for (StackTraceElement el : stack) {
streamWriter.write(el + "\n");
}
streamWriter.flush();
} catch (Exception e) {
e.printStackTrace();
}
}
private static File getNativeLibraryDir(Context context) { private static File getNativeLibraryDir(Context context) {
File f = null; File f = null;
if (context != null) { if (context != null) {
...@@ -133,12 +73,10 @@ public class NativeLoader { ...@@ -133,12 +73,10 @@ public class NativeLoader {
nativeLoaded = true; nativeLoaded = true;
} catch (Error e) { } catch (Error e) {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
writeNativeError(context, "after zip", e);
} }
return true; return true;
} catch (Exception e) { } catch (Exception e) {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
writeNativeError(context, "zip", e);
} finally { } finally {
if (stream != null) { if (stream != null) {
try { try {
...@@ -163,8 +101,6 @@ public class NativeLoader { ...@@ -163,8 +101,6 @@ public class NativeLoader {
return; return;
} }
cleanNativeLog(context);
try { try {
String folder = null; String folder = null;
long libSize = 0; long libSize = 0;
...@@ -193,12 +129,17 @@ public class NativeLoader { ...@@ -193,12 +129,17 @@ public class NativeLoader {
} }
} catch (Exception e) { } catch (Exception e) {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
writeNativeError(context, "arch", e);
folder = "armeabi"; folder = "armeabi";
libSize = sizes[0]; libSize = sizes[0];
libSize2 = sizes[1]; libSize2 = sizes[1];
} }
String javaArch = System.getProperty("os.arch");
if (javaArch != null && javaArch.contains("686")) {
folder = "x86";
libSize = sizes[2];
}
File destFile = getNativeLibraryDir(context); File destFile = getNativeLibraryDir(context);
if (destFile != null) { if (destFile != null) {
destFile = new File(destFile, "libtmessages.so"); destFile = new File(destFile, "libtmessages.so");
...@@ -207,27 +148,23 @@ public class NativeLoader { ...@@ -207,27 +148,23 @@ public class NativeLoader {
try { try {
System.loadLibrary("tmessages"); System.loadLibrary("tmessages");
nativeLoaded = true; nativeLoaded = true;
closeStream();
return; return;
} catch (Error e) { } catch (Error e) {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
writeNativeError(context, "normal", e);
} }
} }
} }
File destLocalFile = new File(context.getFilesDir().getAbsolutePath() + "/libtmessages.so"); File destLocalFile = new File(context.getFilesDir().getAbsolutePath() + "/libtmessages.so");
if (destLocalFile.exists()) { if (destLocalFile != null && destLocalFile.exists()) {
if (destLocalFile.length() == libSize) { if (destLocalFile.length() == libSize) {
try { try {
FileLog.d("tmessages", "Load local lib"); FileLog.d("tmessages", "Load local lib");
System.load(destLocalFile.getAbsolutePath()); System.load(destLocalFile.getAbsolutePath());
nativeLoaded = true; nativeLoaded = true;
closeStream();
return; return;
} catch (Error e) { } catch (Error e) {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
writeNativeError(context, "local", e);
} }
} else { } else {
destLocalFile.delete(); destLocalFile.delete();
...@@ -236,21 +173,23 @@ public class NativeLoader { ...@@ -236,21 +173,23 @@ public class NativeLoader {
FileLog.e("tmessages", "Library not found, arch = " + folder); FileLog.e("tmessages", "Library not found, arch = " + folder);
if (!loadFromZip(context, destLocalFile, folder) && folder.equals("armeabi-v7a")) { if (!loadFromZip(context, destLocalFile, folder)) {
folder = "x86";
destLocalFile = new File(context.getFilesDir().getAbsolutePath() + "/libtmessages86.so");
if (!loadFromZip(context, destLocalFile, folder)) {
destLocalFile = new File(context.getFilesDir().getAbsolutePath() + "/libtmessagesarm.so");
folder = "armeabi"; folder = "armeabi";
loadFromZip(context, destLocalFile, folder); loadFromZip(context, destLocalFile, folder);
} }
}
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
writeNativeError(context, "", e);
} }
try { try {
System.loadLibrary("tmessages"); System.loadLibrary("tmessages");
nativeLoaded = true; nativeLoaded = true;
closeStream();
} catch (Error e) { } catch (Error e) {
writeNativeError(context, "last chance", e);
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
} }
} }
......
...@@ -19,9 +19,11 @@ public class ScreenReceiver extends BroadcastReceiver { ...@@ -19,9 +19,11 @@ public class ScreenReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) { if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
FileLog.e("tmessages", "screen off"); FileLog.e("tmessages", "screen off");
ApplicationLoader.lastPauseTime = System.currentTimeMillis();
ApplicationLoader.isScreenOn = false; ApplicationLoader.isScreenOn = false;
} else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) { } else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
FileLog.e("tmessages", "screen on"); FileLog.e("tmessages", "screen on");
ApplicationLoader.resetLastPauseTime();
ApplicationLoader.isScreenOn = true; ApplicationLoader.isScreenOn = true;
} }
} }
......
...@@ -39,7 +39,6 @@ import net.hockeyapp.android.UpdateManager; ...@@ -39,7 +39,6 @@ import net.hockeyapp.android.UpdateManager;
import org.telegram.ui.ApplicationLoader; import org.telegram.ui.ApplicationLoader;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
...@@ -47,7 +46,6 @@ import java.io.FileInputStream; ...@@ -47,7 +46,6 @@ import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream; import java.io.OutputStream;
import java.math.BigInteger; import java.math.BigInteger;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
...@@ -997,41 +995,6 @@ public class Utilities { ...@@ -997,41 +995,6 @@ public class Utilities {
public boolean includeDeviceData() { public boolean includeDeviceData() {
return true; return true;
} }
@Override
public String getDescription() {
String description = "";
try {
File sdCard = ApplicationLoader.applicationContext.getFilesDir();
if (sdCard == null) {
return description;
}
File file = new File(sdCard, "nativeer.log");
if (file == null || !file.exists()) {
return description;
}
FileInputStream inputStream = new FileInputStream(file);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
StringBuilder log = new StringBuilder();
String line;
while ((line = bufferedReader.readLine()) != null) {
log.append(line);
log.append("\n");
}
bufferedReader.close();
inputStream.close();
description = log.toString();
NativeLoader.cleanNativeLog(ApplicationLoader.applicationContext);
} catch (Exception e) {
e.printStackTrace();
}
return description;
}
}); });
} }
......
...@@ -47,6 +47,7 @@ import org.telegram.ui.Views.ActionBar.ActionBarMenu; ...@@ -47,6 +47,7 @@ import org.telegram.ui.Views.ActionBar.ActionBarMenu;
import org.telegram.ui.Views.AvatarUpdater; import org.telegram.ui.Views.AvatarUpdater;
import org.telegram.ui.Views.BackupImageView; import org.telegram.ui.Views.BackupImageView;
import org.telegram.ui.Views.ActionBar.BaseFragment; import org.telegram.ui.Views.ActionBar.BaseFragment;
import org.telegram.ui.Views.ColorPickerView;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
...@@ -71,10 +72,12 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen ...@@ -71,10 +72,12 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
private int settingsSectionRow; private int settingsSectionRow;
private int settingsNotificationsRow; private int settingsNotificationsRow;
private int settingsVibrateRow; private int settingsVibrateRow;
private int settingsLedRow;
private int settingsSoundRow; private int settingsSoundRow;
private int sharedMediaSectionRow; private int sharedMediaSectionRow;
private int sharedMediaRow; private int sharedMediaRow;
private int membersSectionRow; private int membersSectionRow;
private int membersEndRow;
private int addMemberRow; private int addMemberRow;
private int leaveGroupRow; private int leaveGroupRow;
private int rowCount = 0; private int rowCount = 0;
...@@ -140,18 +143,21 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen ...@@ -140,18 +143,21 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
settingsSectionRow = rowCount++; settingsSectionRow = rowCount++;
settingsNotificationsRow = rowCount++; settingsNotificationsRow = rowCount++;
settingsVibrateRow = rowCount++; settingsVibrateRow = rowCount++;
settingsLedRow = rowCount++;
settingsSoundRow = rowCount++; settingsSoundRow = rowCount++;
sharedMediaSectionRow = rowCount++; sharedMediaSectionRow = rowCount++;
sharedMediaRow = rowCount++; sharedMediaRow = rowCount++;
if (info != null && !(info instanceof TLRPC.TL_chatParticipantsForbidden)) { if (info != null && !(info instanceof TLRPC.TL_chatParticipantsForbidden)) {
membersSectionRow = rowCount++; membersSectionRow = rowCount++;
rowCount += info.participants.size(); rowCount += info.participants.size();
membersEndRow = rowCount;
if (info.participants.size() < 200) { if (info.participants.size() < 200) {
addMemberRow = rowCount++; addMemberRow = rowCount++;
} else { } else {
addMemberRow = -1; addMemberRow = -1;
} }
} else { } else {
membersEndRow = -1;
addMemberRow = -1; addMemberRow = -1;
membersSectionRow = -1; membersSectionRow = -1;
} }
...@@ -197,7 +203,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen ...@@ -197,7 +203,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override @Override
public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) { public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
if (i > membersSectionRow && i < addMemberRow) { if (i > membersSectionRow && i < membersEndRow) {
if (getParentActivity() == null) { if (getParentActivity() == null) {
return false; return false;
} }
...@@ -268,7 +274,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen ...@@ -268,7 +274,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
presentFragment(new MediaActivity(args)); presentFragment(new MediaActivity(args));
} else if (i == addMemberRow) { } else if (i == addMemberRow) {
openAddMenu(); openAddMenu();
} else if (i > membersSectionRow && i < addMemberRow) { } else if (i > membersSectionRow && i < membersEndRow) {
int user_id = info.participants.get(sortedUsers.get(i - membersSectionRow - 1)).user_id; int user_id = info.participants.get(sortedUsers.get(i - membersSectionRow - 1)).user_id;
if (user_id == UserConfig.getClientUserId()) { if (user_id == UserConfig.getClientUserId()) {
return; return;
...@@ -304,6 +310,56 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen ...@@ -304,6 +310,56 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
}); });
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showAlertDialog(builder); showAlertDialog(builder);
} else if (i == settingsLedRow) {
if (getParentActivity() == null) {
return;
}
LayoutInflater li = (LayoutInflater)getParentActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = li.inflate(R.layout.settings_color_dialog_layout, null, false);
final ColorPickerView colorPickerView = (ColorPickerView)view.findViewById(R.id.color_picker);
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
if (preferences.contains("color_" + (-chat_id))) {
colorPickerView.setOldCenterColor(preferences.getInt("color_" + (-chat_id), 0xff00ff00));
} else {
colorPickerView.setOldCenterColor(preferences.getInt("GroupLed", 0xff00ff00));
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("LedColor", R.string.LedColor));
builder.setView(view);
builder.setPositiveButton(LocaleController.getString("Set", R.string.Set), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int which) {
final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putInt("color_" + (-chat_id), colorPickerView.getColor());
editor.commit();
listView.invalidateViews();
}
});
builder.setNeutralButton(LocaleController.getString("Disabled", R.string.Disabled), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putInt("color_" + (-chat_id), 0);
editor.commit();
listView.invalidateViews();
}
});
builder.setNegativeButton(LocaleController.getString("Default", R.string.Default), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.remove("color_" + (-chat_id));
editor.commit();
listView.invalidateViews();
}
});
showAlertDialog(builder);
} }
} }
}); });
...@@ -588,7 +644,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen ...@@ -588,7 +644,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
@Override @Override
public boolean isEnabled(int i) { public boolean isEnabled(int i) {
return i == settingsNotificationsRow || i == settingsSoundRow || i == sharedMediaRow || i > membersSectionRow && i <= addMemberRow || i == settingsVibrateRow; return i == settingsNotificationsRow || i == settingsSoundRow || i == sharedMediaRow || i == addMemberRow || i > membersSectionRow && i < membersEndRow || i == settingsVibrateRow || i == settingsLedRow;
} }
@Override @Override
...@@ -830,6 +886,23 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen ...@@ -830,6 +886,23 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
textView.setText(LocaleController.getString("Sound", R.string.Sound)); textView.setText(LocaleController.getString("Sound", R.string.Sound));
divider.setVisibility(View.INVISIBLE); divider.setVisibility(View.INVISIBLE);
} }
} else if (type == 7) {
if (view == null) {
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = li.inflate(R.layout.settings_row_color_layout, viewGroup, false);
}
TextView textView = (TextView)view.findViewById(R.id.settings_row_text);
View colorView = view.findViewById(R.id.settings_color);
View divider = view.findViewById(R.id.settings_row_divider);
textView.setText(LocaleController.getString("LedColor", R.string.LedColor));
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
if (preferences.contains("color_" + (-chat_id))) {
colorView.setBackgroundColor(preferences.getInt("color_" + (-chat_id), 0xff00ff00));
} else {
colorView.setBackgroundColor(preferences.getInt("GroupLed", 0xff00ff00));
}
divider.setVisibility(View.VISIBLE);
} }
return view; return view;
} }
...@@ -848,15 +921,17 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen ...@@ -848,15 +921,17 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
return 4; return 4;
} else if (i == leaveGroupRow) { } else if (i == leaveGroupRow) {
return 5; return 5;
} else if (i > membersSectionRow && i < addMemberRow) { } else if (i > membersSectionRow && i < membersEndRow) {
return 3; return 3;
} else if (i == settingsLedRow) {
return 7;
} }
return 0; return 0;
} }
@Override @Override
public int getViewTypeCount() { public int getViewTypeCount() {
return 7; return 8;
} }
@Override @Override
......
...@@ -100,6 +100,9 @@ public class PhotoCropActivity extends BaseFragment { ...@@ -100,6 +100,9 @@ public class PhotoCropActivity extends BaseFragment {
} else { } else {
draggingState = 0; draggingState = 0;
} }
if (draggingState != 0) {
PhotoCropView.this.requestDisallowInterceptTouchEvent(true);
}
oldX = x; oldX = x;
oldY = y; oldY = y;
} else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
......
...@@ -39,6 +39,7 @@ import org.telegram.messenger.RPCRequest; ...@@ -39,6 +39,7 @@ import org.telegram.messenger.RPCRequest;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
import org.telegram.ui.Views.ActionBar.ActionBarLayer; import org.telegram.ui.Views.ActionBar.ActionBarLayer;
import org.telegram.ui.Views.ActionBar.BaseFragment; import org.telegram.ui.Views.ActionBar.BaseFragment;
import org.telegram.ui.Views.ColorPickerView;
public class SettingsNotificationsActivity extends BaseFragment { public class SettingsNotificationsActivity extends BaseFragment {
private ListView listView; private ListView listView;
...@@ -50,11 +51,13 @@ public class SettingsNotificationsActivity extends BaseFragment { ...@@ -50,11 +51,13 @@ public class SettingsNotificationsActivity extends BaseFragment {
private int messagePreviewRow; private int messagePreviewRow;
private int messageVibrateRow; private int messageVibrateRow;
private int messageSoundRow; private int messageSoundRow;
private int messageLedRow;
private int groupSectionRow; private int groupSectionRow;
private int groupAlertRow; private int groupAlertRow;
private int groupPreviewRow; private int groupPreviewRow;
private int groupVibrateRow; private int groupVibrateRow;
private int groupSoundRow; private int groupSoundRow;
private int groupLedRow;
private int inappSectionRow; private int inappSectionRow;
private int inappSoundRow; private int inappSoundRow;
private int inappVibrateRow; private int inappVibrateRow;
...@@ -74,11 +77,13 @@ public class SettingsNotificationsActivity extends BaseFragment { ...@@ -74,11 +77,13 @@ public class SettingsNotificationsActivity extends BaseFragment {
messageAlertRow = rowCount++; messageAlertRow = rowCount++;
messagePreviewRow = rowCount++; messagePreviewRow = rowCount++;
messageVibrateRow = rowCount++; messageVibrateRow = rowCount++;
messageLedRow = rowCount++;
messageSoundRow = rowCount++; messageSoundRow = rowCount++;
groupSectionRow = rowCount++; groupSectionRow = rowCount++;
groupAlertRow = rowCount++; groupAlertRow = rowCount++;
groupPreviewRow = rowCount++; groupPreviewRow = rowCount++;
groupVibrateRow = rowCount++; groupVibrateRow = rowCount++;
groupLedRow = rowCount++;
groupSoundRow = rowCount++; groupSoundRow = rowCount++;
inappSectionRow = rowCount++; inappSectionRow = rowCount++;
inappSoundRow = rowCount++; inappSoundRow = rowCount++;
...@@ -110,12 +115,12 @@ public class SettingsNotificationsActivity extends BaseFragment { ...@@ -110,12 +115,12 @@ public class SettingsNotificationsActivity extends BaseFragment {
}); });
fragmentView = inflater.inflate(R.layout.settings_layout, container, false); fragmentView = inflater.inflate(R.layout.settings_layout, container, false);
ListAdapter listAdapter = new ListAdapter(getParentActivity()); final ListAdapter listAdapter = new ListAdapter(getParentActivity());
listView = (ListView)fragmentView.findViewById(R.id.listView); listView = (ListView)fragmentView.findViewById(R.id.listView);
listView.setAdapter(listAdapter); listView.setAdapter(listAdapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override @Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
if (i == messageAlertRow || i == groupAlertRow) { if (i == messageAlertRow || i == groupAlertRow) {
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit(); SharedPreferences.Editor editor = preferences.edit();
...@@ -289,6 +294,54 @@ public class SettingsNotificationsActivity extends BaseFragment { ...@@ -289,6 +294,54 @@ public class SettingsNotificationsActivity extends BaseFragment {
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showAlertDialog(builder); showAlertDialog(builder);
} }
} else if (i == messageLedRow || i == groupLedRow) {
if (getParentActivity() == null) {
return;
}
LayoutInflater li = (LayoutInflater)getParentActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = li.inflate(R.layout.settings_color_dialog_layout, null, false);
final ColorPickerView colorPickerView = (ColorPickerView)view.findViewById(R.id.color_picker);
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
if (i == messageLedRow) {
colorPickerView.setOldCenterColor(preferences.getInt("MessagesLed", 0xff00ff00));
} else if (i == groupLedRow) {
colorPickerView.setOldCenterColor(preferences.getInt("GroupLed", 0xff00ff00));
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("LedColor", R.string.LedColor));
builder.setView(view);
builder.setPositiveButton(LocaleController.getString("Set", R.string.Set), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int which) {
final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
if (i == messageLedRow) {
editor.putInt("MessagesLed", colorPickerView.getColor());
} else if (i == groupLedRow) {
editor.putInt("GroupLed", colorPickerView.getColor());
}
editor.commit();
listView.invalidateViews();
}
});
builder.setNeutralButton(LocaleController.getString("Disabled", R.string.Disabled), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
if (i == messageLedRow) {
editor.putInt("MessagesLed", 0);
} else if (i == groupLedRow) {
editor.putInt("GroupLed", 0);
}
editor.commit();
listView.invalidateViews();
}
});
showAlertDialog(builder);
} }
} }
}); });
...@@ -501,8 +554,23 @@ public class SettingsNotificationsActivity extends BaseFragment { ...@@ -501,8 +554,23 @@ public class SettingsNotificationsActivity extends BaseFragment {
textViewDetail.setText(LocaleController.getString("UndoAllCustom", R.string.UndoAllCustom)); textViewDetail.setText(LocaleController.getString("UndoAllCustom", R.string.UndoAllCustom));
divider.setVisibility(View.INVISIBLE); divider.setVisibility(View.INVISIBLE);
} }
} else if (type == 3) {
if (view == null) {
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = li.inflate(R.layout.settings_row_color_layout, viewGroup, false);
}
TextView textView = (TextView)view.findViewById(R.id.settings_row_text);
View colorView = view.findViewById(R.id.settings_color);
View divider = view.findViewById(R.id.settings_row_divider);
textView.setText(LocaleController.getString("LedColor", R.string.LedColor));
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
if (i == messageLedRow) {
colorView.setBackgroundColor(preferences.getInt("MessagesLed", 0xff00ff00));
} else if (i == groupLedRow) {
colorView.setBackgroundColor(preferences.getInt("GroupLed", 0xff00ff00));
}
divider.setVisibility(View.VISIBLE);
} }
return view; return view;
} }
...@@ -516,6 +584,8 @@ public class SettingsNotificationsActivity extends BaseFragment { ...@@ -516,6 +584,8 @@ public class SettingsNotificationsActivity extends BaseFragment {
i == contactJoinedRow || i == contactJoinedRow ||
i == pebbleAlertRow || i == notificationsServiceRow) { i == pebbleAlertRow || i == notificationsServiceRow) {
return 1; return 1;
} else if (i == messageLedRow || i == groupLedRow) {
return 3;
} else { } else {
return 2; return 2;
} }
...@@ -523,7 +593,7 @@ public class SettingsNotificationsActivity extends BaseFragment { ...@@ -523,7 +593,7 @@ public class SettingsNotificationsActivity extends BaseFragment {
@Override @Override
public int getViewTypeCount() { public int getViewTypeCount() {
return 3; return 4;
} }
@Override @Override
......
...@@ -48,6 +48,7 @@ import org.telegram.ui.Views.ActionBar.ActionBarMenu; ...@@ -48,6 +48,7 @@ import org.telegram.ui.Views.ActionBar.ActionBarMenu;
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem; import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
import org.telegram.ui.Views.BackupImageView; import org.telegram.ui.Views.BackupImageView;
import org.telegram.ui.Views.ActionBar.BaseFragment; import org.telegram.ui.Views.ActionBar.BaseFragment;
import org.telegram.ui.Views.ColorPickerView;
import org.telegram.ui.Views.IdenticonView; import org.telegram.ui.Views.IdenticonView;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -79,6 +80,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen ...@@ -79,6 +80,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
private int settingsSoundRow; private int settingsSoundRow;
private int sharedMediaSectionRow; private int sharedMediaSectionRow;
private int sharedMediaRow; private int sharedMediaRow;
private int settingsLedRow;
private int rowCount = 0; private int rowCount = 0;
public UserProfileActivity(Bundle args) { public UserProfileActivity(Bundle args) {
...@@ -126,6 +128,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen ...@@ -126,6 +128,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
} }
settingsNotificationsRow = rowCount++; settingsNotificationsRow = rowCount++;
settingsVibrateRow = rowCount++; settingsVibrateRow = rowCount++;
settingsLedRow = rowCount++;
settingsSoundRow = rowCount++; settingsSoundRow = rowCount++;
sharedMediaSectionRow = rowCount++; sharedMediaSectionRow = rowCount++;
sharedMediaRow = rowCount++; sharedMediaRow = rowCount++;
...@@ -373,6 +376,57 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen ...@@ -373,6 +376,57 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
}); });
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showAlertDialog(builder); showAlertDialog(builder);
} else if (i == settingsLedRow) {
if (getParentActivity() == null) {
return;
}
LayoutInflater li = (LayoutInflater)getParentActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = li.inflate(R.layout.settings_color_dialog_layout, null, false);
final ColorPickerView colorPickerView = (ColorPickerView)view.findViewById(R.id.color_picker);
final String key = dialog_id == 0 ? "color_" + user_id : "color_" + dialog_id;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
if (preferences.contains(key)) {
colorPickerView.setOldCenterColor(preferences.getInt(key, 0xff00ff00));
} else {
colorPickerView.setOldCenterColor(preferences.getInt("MessagesLed", 0xff00ff00));
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("LedColor", R.string.LedColor));
builder.setView(view);
builder.setPositiveButton(LocaleController.getString("Set", R.string.Set), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int which) {
final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putInt(key, colorPickerView.getColor());
editor.commit();
listView.invalidateViews();
}
});
builder.setNeutralButton(LocaleController.getString("Disabled", R.string.Disabled), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putInt(key, 0);
editor.commit();
listView.invalidateViews();
}
});
builder.setNegativeButton(LocaleController.getString("Default", R.string.Default), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.remove(key);
editor.commit();
listView.invalidateViews();
}
});
showAlertDialog(builder);
} }
} }
}); });
...@@ -589,7 +643,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen ...@@ -589,7 +643,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
@Override @Override
public boolean isEnabled(int i) { public boolean isEnabled(int i) {
return i == phoneRow || i == settingsTimerRow || i == settingsKeyRow || i == settingsNotificationsRow || i == sharedMediaRow || i == settingsSoundRow || i == settingsVibrateRow; return i == phoneRow || i == settingsTimerRow || i == settingsKeyRow || i == settingsNotificationsRow || i == sharedMediaRow || i == settingsSoundRow || i == settingsVibrateRow || i == settingsLedRow;
} }
@Override @Override
...@@ -846,8 +900,25 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen ...@@ -846,8 +900,25 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
textView.setText(LocaleController.getString("Sound", R.string.Sound)); textView.setText(LocaleController.getString("Sound", R.string.Sound));
divider.setVisibility(View.INVISIBLE); divider.setVisibility(View.INVISIBLE);
} }
} else if (type == 6) {
if (view == null) {
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = li.inflate(R.layout.settings_row_color_layout, viewGroup, false);
} }
TextView textView = (TextView)view.findViewById(R.id.settings_row_text);
View colorView = view.findViewById(R.id.settings_color);
View divider = view.findViewById(R.id.settings_row_divider);
textView.setText(LocaleController.getString("LedColor", R.string.LedColor));
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
String key = dialog_id == 0 ? "color_" + user_id : "color_" + dialog_id;
if (preferences.contains(key)) {
colorView.setBackgroundColor(preferences.getInt(key, 0xff00ff00));
} else {
colorView.setBackgroundColor(preferences.getInt("MessagesLed", 0xff00ff00));
}
divider.setVisibility(View.VISIBLE);
}
return view; return view;
} }
...@@ -865,13 +936,15 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen ...@@ -865,13 +936,15 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
return 4; return 4;
} else if (i == settingsSoundRow) { } else if (i == settingsSoundRow) {
return 5; return 5;
} else if (i == settingsLedRow) {
return 6;
} }
return 0; return 0;
} }
@Override @Override
public int getViewTypeCount() { public int getViewTypeCount() {
return 6; return 7;
} }
@Override @Override
......
...@@ -9,13 +9,14 @@ ...@@ -9,13 +9,14 @@
package org.telegram.ui.Views.ActionBar; package org.telegram.ui.Views.ActionBar;
import android.content.Context; import android.content.Context;
import android.graphics.drawable.BitmapDrawable; import android.graphics.Rect;
import android.os.Build; import android.os.Build;
import android.text.Editable; import android.text.Editable;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.Gravity; import android.view.Gravity;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
...@@ -38,13 +39,16 @@ public class ActionBarMenuItem extends ImageView { ...@@ -38,13 +39,16 @@ public class ActionBarMenuItem extends ImageView {
public abstract void onTextChanged(EditText editText); public abstract void onTextChanged(EditText editText);
} }
private LinearLayout popupLayout; private ActionBarPopupWindow.ActionBarPopupWindowLayout popupLayout;
private ActionBarMenu parentMenu; private ActionBarMenu parentMenu;
private ActionBarPopupWindow popupWindow; private ActionBarPopupWindow popupWindow;
private ActionBar parentActionBar; private ActionBar parentActionBar;
private EditText searchField; private EditText searchField;
private boolean isSearchField = false; private boolean isSearchField = false;
private ActionBarMenuItemSearchListener listener; private ActionBarMenuItemSearchListener listener;
private Rect rect = null;
private int[] location = null;
private View selectedMenuView = null;
public ActionBarMenuItem(Context context, ActionBarMenu menu, ActionBar actionBar, int background) { public ActionBarMenuItem(Context context, ActionBarMenu menu, ActionBar actionBar, int background) {
super(context); super(context);
...@@ -65,11 +69,82 @@ public class ActionBarMenuItem extends ImageView { ...@@ -65,11 +69,82 @@ public class ActionBarMenuItem extends ImageView {
super(context, attrs, defStyleAttr); super(context, attrs, defStyleAttr);
} }
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getActionMasked() == MotionEvent.ACTION_MOVE) {
if (hasSubMenu() && (popupWindow == null || popupWindow != null && !popupWindow.isShowing())) {
if (event.getY() > getHeight()) {
if (getParent() != null) {
getParent().requestDisallowInterceptTouchEvent(true);
}
toggleSubMenu();
return true;
}
} else if (popupWindow != null && popupWindow.isShowing()) {
getLocationOnScreen(location);
float x = event.getX() + location[0];
float y = event.getY() + location[1];
popupLayout.getLocationOnScreen(location);
x -= location[0];
y -= location[1];
selectedMenuView = null;
for (int a = 0; a < popupLayout.getChildCount(); a++) {
View child = popupLayout.getChildAt(a);
child.getHitRect(rect);
if ((Integer)child.getTag() < 100) {
if (!rect.contains((int)x, (int)y)) {
child.setSelected(false);
} else {
child.setSelected(true);
selectedMenuView = child;
}
}
}
}
} else if (popupWindow != null && popupWindow.isShowing() && event.getActionMasked() == MotionEvent.ACTION_UP) {
if (selectedMenuView != null) {
selectedMenuView.setSelected(false);
parentMenu.onItemClick((Integer) selectedMenuView.getTag());
}
popupWindow.dismiss();
} else {
if (selectedMenuView != null) {
selectedMenuView.setSelected(false);
selectedMenuView = null;
}
}
return super.onTouchEvent(event);
}
public void addSubItem(int id, String text, int icon) { public void addSubItem(int id, String text, int icon) {
if (popupLayout == null) { if (popupLayout == null) {
popupLayout = new LinearLayout(getContext()); rect = new Rect();
location = new int[2];
popupLayout = new ActionBarPopupWindow.ActionBarPopupWindowLayout(getContext());
popupLayout.setOrientation(LinearLayout.VERTICAL); popupLayout.setOrientation(LinearLayout.VERTICAL);
popupLayout.setBackgroundResource(R.drawable.popup_fixed); popupLayout.setBackgroundResource(R.drawable.popup_fixed);
popupLayout.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
if (popupWindow != null && popupWindow.isShowing()) {
v.getHitRect(rect);
if (!rect.contains((int)event.getX(), (int)event.getY())) {
popupWindow.dismiss();
}
}
}
return false;
}
});
popupLayout.setDispatchKeyEventListener(new ActionBarPopupWindow.OnDispatchKeyEventListener() {
@Override
public void onDispatchKeyEvent(KeyEvent keyEvent) {
if (keyEvent.getKeyCode() == KeyEvent.KEYCODE_BACK && keyEvent.getRepeatCount() == 0 && popupWindow != null && popupWindow.isShowing()) {
popupWindow.dismiss();
}
}
});
} }
if (popupLayout.getChildCount() != 0) { if (popupLayout.getChildCount() != 0) {
View delimeter = new View(getContext()); View delimeter = new View(getContext());
...@@ -121,7 +196,7 @@ public class ActionBarMenuItem extends ImageView { ...@@ -121,7 +196,7 @@ public class ActionBarMenuItem extends ImageView {
} }
if (popupWindow == null) { if (popupWindow == null) {
popupWindow = new ActionBarPopupWindow(popupLayout, FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); popupWindow = new ActionBarPopupWindow(popupLayout, FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
popupWindow.setBackgroundDrawable(new BitmapDrawable()); //popupWindow.setBackgroundDrawable(new BitmapDrawable());
popupWindow.setOutsideTouchable(true); popupWindow.setOutsideTouchable(true);
popupWindow.setClippingEnabled(true); popupWindow.setClippingEnabled(true);
popupWindow.setInputMethodMode(ActionBarPopupWindow.INPUT_METHOD_NOT_NEEDED); popupWindow.setInputMethodMode(ActionBarPopupWindow.INPUT_METHOD_NOT_NEEDED);
......
...@@ -12,8 +12,10 @@ package org.telegram.ui.Views.ActionBar; ...@@ -12,8 +12,10 @@ package org.telegram.ui.Views.ActionBar;
import android.content.Context; import android.content.Context;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.View; import android.view.View;
import android.view.ViewTreeObserver; import android.view.ViewTreeObserver;
import android.widget.LinearLayout;
import android.widget.PopupWindow; import android.widget.PopupWindow;
import java.lang.reflect.Field; import java.lang.reflect.Field;
...@@ -41,6 +43,39 @@ public class ActionBarPopupWindow extends PopupWindow { ...@@ -41,6 +43,39 @@ public class ActionBarPopupWindow extends PopupWindow {
private ViewTreeObserver.OnScrollChangedListener mSuperScrollListener; private ViewTreeObserver.OnScrollChangedListener mSuperScrollListener;
private ViewTreeObserver mViewTreeObserver; private ViewTreeObserver mViewTreeObserver;
public static interface OnDispatchKeyEventListener {
public void onDispatchKeyEvent(KeyEvent keyEvent);
}
public static class ActionBarPopupWindowLayout extends LinearLayout {
private OnDispatchKeyEventListener mOnDispatchKeyEventListener;
public ActionBarPopupWindowLayout(Context context) {
super(context);
}
public ActionBarPopupWindowLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public ActionBarPopupWindowLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public void setDispatchKeyEventListener(OnDispatchKeyEventListener listener) {
mOnDispatchKeyEventListener = listener;
}
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if (mOnDispatchKeyEventListener != null) {
mOnDispatchKeyEventListener.onDispatchKeyEvent(event);
}
return super.dispatchKeyEvent(event);
}
}
public ActionBarPopupWindow() { public ActionBarPopupWindow() {
super(); super();
init(); init();
...@@ -98,7 +133,6 @@ public class ActionBarPopupWindow extends PopupWindow { ...@@ -98,7 +133,6 @@ public class ActionBarPopupWindow extends PopupWindow {
} }
private void unregisterListener() { private void unregisterListener() {
// Don't do anything if we haven't managed to patch the super listener
if (mSuperScrollListener != null && mViewTreeObserver != null) { if (mSuperScrollListener != null && mViewTreeObserver != null) {
if (mViewTreeObserver.isAlive()) { if (mViewTreeObserver.isAlive()) {
mViewTreeObserver.removeOnScrollChangedListener(mSuperScrollListener); mViewTreeObserver.removeOnScrollChangedListener(mSuperScrollListener);
...@@ -108,13 +142,8 @@ public class ActionBarPopupWindow extends PopupWindow { ...@@ -108,13 +142,8 @@ public class ActionBarPopupWindow extends PopupWindow {
} }
private void registerListener(View anchor) { private void registerListener(View anchor) {
// Don't do anything if we haven't managed to patch the super listener.
// And don't bother attaching the listener if the anchor view isn't
// attached. This means we'll only have to deal with the real VTO owned
// by the ViewRoot.
if (mSuperScrollListener != null) { if (mSuperScrollListener != null) {
ViewTreeObserver vto = (anchor.getWindowToken() != null) ? anchor.getViewTreeObserver() ViewTreeObserver vto = (anchor.getWindowToken() != null) ? anchor.getViewTreeObserver() : null;
: null;
if (vto != mViewTreeObserver) { if (vto != mViewTreeObserver) {
if (mViewTreeObserver != null && mViewTreeObserver.isAlive()) { if (mViewTreeObserver != null && mViewTreeObserver.isAlive()) {
mViewTreeObserver.removeOnScrollChangedListener(mSuperScrollListener); mViewTreeObserver.removeOnScrollChangedListener(mSuperScrollListener);
......
<!--
~ This is the source code of Telegram for Android v. 1.4.x.
~ It is licensed under GNU GPL v. 2 or later.
~ You should have received a copy of the license in this archive (see LICENSE).
~
~ Copyright Nikolai Kudashov, 2013-2014.
-->
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_gravity="top">
<FrameLayout
android:id="@+id/settings_color"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginLeft="14dp"
android:layout_marginRight="8dp"
android:layout_gravity="center_vertical"/>
<TextView
android:textSize="18dp"
android:textColor="#333333"
android:id="@+id/settings_row_text"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:gravity="center_vertical|right"
android:layout_gravity="top|right"/>
<View
android:background="@color/divider"
android:layout_width="fill_parent"
android:layout_height="1px"
android:layout_gravity="bottom"
android:id="@+id/settings_row_divider"/>
</FrameLayout>
\ No newline at end of file
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center">
<org.telegram.ui.Views.ColorPickerView
android:id="@+id/color_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
</LinearLayout>
\ No newline at end of file
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_gravity="top">
<TextView
android:textSize="18dp"
android:textColor="#333333"
android:id="@+id/settings_row_text"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:gravity="center_vertical"
android:layout_gravity="top"/>
<FrameLayout
android:id="@+id/settings_color"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="14dp"
android:layout_gravity="center_vertical|right"/>
<View
android:background="@color/divider"
android:layout_width="fill_parent"
android:layout_height="1px"
android:layout_gravity="bottom"
android:id="@+id/settings_row_divider"/>
</FrameLayout>
\ No newline at end of file
...@@ -273,6 +273,7 @@ ...@@ -273,6 +273,7 @@
<string name="WiFiOnly">بواسطة WiFi فقط</string> <string name="WiFiOnly">بواسطة WiFi فقط</string>
<string name="SortFirstName">الاسم الأول</string> <string name="SortFirstName">الاسم الأول</string>
<string name="SortLastName">اسم العائلة</string> <string name="SortLastName">اسم العائلة</string>
<string name="LedColor">LED Color</string>
<!--media view--> <!--media view-->
<string name="NoMedia">لا توجد وسائط بعد</string> <string name="NoMedia">لا توجد وسائط بعد</string>
......
...@@ -273,6 +273,7 @@ ...@@ -273,6 +273,7 @@
<string name="WiFiOnly">nur über WLAN</string> <string name="WiFiOnly">nur über WLAN</string>
<string name="SortFirstName">Vorname</string> <string name="SortFirstName">Vorname</string>
<string name="SortLastName">Nachname</string> <string name="SortLastName">Nachname</string>
<string name="LedColor">LED Color</string>
<!--media view--> <!--media view-->
<string name="NoMedia">Noch keine geteilten Medien vorhanden</string> <string name="NoMedia">Noch keine geteilten Medien vorhanden</string>
......
...@@ -273,6 +273,7 @@ ...@@ -273,6 +273,7 @@
<string name="WiFiOnly">Sólo vía WiFi</string> <string name="WiFiOnly">Sólo vía WiFi</string>
<string name="SortFirstName">Nombre</string> <string name="SortFirstName">Nombre</string>
<string name="SortLastName">Apellido</string> <string name="SortLastName">Apellido</string>
<string name="LedColor">LED Color</string>
<!--media view--> <!--media view-->
<string name="NoMedia">No hay fotos ni vídeos compartidos aún</string> <string name="NoMedia">No hay fotos ni vídeos compartidos aún</string>
......
...@@ -273,6 +273,7 @@ ...@@ -273,6 +273,7 @@
<string name="WiFiOnly">Solo tramite WiFi</string> <string name="WiFiOnly">Solo tramite WiFi</string>
<string name="SortFirstName">Nome</string> <string name="SortFirstName">Nome</string>
<string name="SortLastName">Cognome</string> <string name="SortLastName">Cognome</string>
<string name="LedColor">LED Color</string>
<!--media view--> <!--media view-->
<string name="NoMedia">Nessun media condiviso</string> <string name="NoMedia">Nessun media condiviso</string>
......
...@@ -273,6 +273,7 @@ ...@@ -273,6 +273,7 @@
<string name="WiFiOnly">Alleen via WiFi</string> <string name="WiFiOnly">Alleen via WiFi</string>
<string name="SortFirstName">Voornaam</string> <string name="SortFirstName">Voornaam</string>
<string name="SortLastName">Achternaam</string> <string name="SortLastName">Achternaam</string>
<string name="LedColor">LED Color</string>
<!--media view--> <!--media view-->
<string name="NoMedia">Nog geen media gedeeld</string> <string name="NoMedia">Nog geen media gedeeld</string>
......
...@@ -273,6 +273,7 @@ ...@@ -273,6 +273,7 @@
<string name="WiFiOnly">Unicamente com WiFi</string> <string name="WiFiOnly">Unicamente com WiFi</string>
<string name="SortFirstName">Primeiro nome</string> <string name="SortFirstName">Primeiro nome</string>
<string name="SortLastName">Sobrenome</string> <string name="SortLastName">Sobrenome</string>
<string name="LedColor">LED Color</string>
<!--media view--> <!--media view-->
<string name="NoMedia">Ainda não há mídia compartilhada</string> <string name="NoMedia">Ainda não há mídia compartilhada</string>
......
...@@ -273,6 +273,7 @@ ...@@ -273,6 +273,7 @@
<string name="WiFiOnly">Unicamente com WiFi</string> <string name="WiFiOnly">Unicamente com WiFi</string>
<string name="SortFirstName">Nome</string> <string name="SortFirstName">Nome</string>
<string name="SortLastName">Apelidos</string> <string name="SortLastName">Apelidos</string>
<string name="LedColor">LED Color</string>
<!--media view--> <!--media view-->
<string name="NoMedia">Ainda não há multimédia partilhado</string> <string name="NoMedia">Ainda não há multimédia partilhado</string>
......
...@@ -273,6 +273,7 @@ ...@@ -273,6 +273,7 @@
<string name="WiFiOnly">Via WiFi only</string> <string name="WiFiOnly">Via WiFi only</string>
<string name="SortFirstName">First name</string> <string name="SortFirstName">First name</string>
<string name="SortLastName">Last name</string> <string name="SortLastName">Last name</string>
<string name="LedColor">LED Color</string>
<!--media view--> <!--media view-->
<string name="NoMedia">No shared media yet</string> <string name="NoMedia">No shared media yet</string>
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment