update to 1.4.7
Pebble notifications (thanks to https://github.com/DrKLO/Telegram/pull/318) Fixed native lib load on android 4.0
This commit is contained in:
parent
6be743c9c2
commit
4b6fb69f30
@ -82,7 +82,7 @@ android {
|
||||
defaultConfig {
|
||||
minSdkVersion 8
|
||||
targetSdkVersion 19
|
||||
versionCode 207
|
||||
versionName "1.4.6"
|
||||
versionCode 208
|
||||
versionName "1.4.7"
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,8 @@ import android.support.v7.app.ActionBarActivity;
|
||||
import android.text.Html;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.telegram.objects.MessageObject;
|
||||
import org.telegram.objects.PhotoObject;
|
||||
import org.telegram.ui.LaunchActivity;
|
||||
@ -4516,6 +4518,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
notification.flags |= Notification.FLAG_SHOW_LIGHTS;
|
||||
try {
|
||||
mNotificationManager.notify(1, notification);
|
||||
if (preferences.getBoolean("EnablePebbleNotifications", false)) {
|
||||
sendAlertToPebble(msg);
|
||||
}
|
||||
currentPushMessage = messageObject;
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
@ -4523,6 +4528,26 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
}
|
||||
}
|
||||
|
||||
public void sendAlertToPebble(String message) {
|
||||
try {
|
||||
final Intent i = new Intent("com.getpebble.action.SEND_NOTIFICATION");
|
||||
|
||||
final HashMap<String, String> data = new HashMap<String, String>();
|
||||
data.put("title", LocaleController.getString("AppName", R.string.AppName));
|
||||
data.put("body", message);
|
||||
final JSONObject jsonData = new JSONObject(data);
|
||||
final String notificationData = new JSONArray().put(jsonData).toString();
|
||||
|
||||
i.putExtra("messageType", "PEBBLE_ALERT");
|
||||
i.putExtra("sender", "MyAndroidApp");
|
||||
i.putExtra("notificationData", notificationData);
|
||||
|
||||
ApplicationLoader.applicationContext.sendBroadcast(i);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void dialogsUnreadCountIncr(final HashMap<Long, Integer> values) {
|
||||
Utilities.RunOnUIThread(new Runnable() {
|
||||
@Override
|
||||
|
@ -33,10 +33,12 @@ public class NativeLoader {
|
||||
try {
|
||||
String folder = null;
|
||||
long libSize = 0;
|
||||
long libSize2 = 0;
|
||||
|
||||
if (Build.CPU_ABI.equalsIgnoreCase("armeabi-v7a")) {
|
||||
folder = "armeabi-v7a";
|
||||
libSize = sizes[1];
|
||||
libSize2 = sizes[0];
|
||||
} else if (Build.CPU_ABI.equalsIgnoreCase("armeabi")) {
|
||||
folder = "armeabi";
|
||||
libSize = sizes[0];
|
||||
@ -53,10 +55,14 @@ public class NativeLoader {
|
||||
}
|
||||
|
||||
File destFile = new File(context.getApplicationInfo().nativeLibraryDir + "/libtmessages.so");
|
||||
if (destFile.exists() && destFile.length() == libSize) {
|
||||
if (destFile.exists() && (destFile.length() == libSize || libSize2 != 0 && destFile.length() == libSize2)) {
|
||||
Log.d("tmessages", "Load normal lib");
|
||||
System.loadLibrary("tmessages");
|
||||
return;
|
||||
try {
|
||||
System.loadLibrary("tmessages");
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
File destLocalFile = new File(context.getFilesDir().getAbsolutePath() + "/libtmessages.so");
|
||||
@ -64,6 +70,7 @@ public class NativeLoader {
|
||||
if (destLocalFile.length() == libSize) {
|
||||
Log.d("tmessages", "Load local lib");
|
||||
System.load(destLocalFile.getAbsolutePath());
|
||||
return;
|
||||
} else {
|
||||
destLocalFile.delete();
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ public class SettingsNotificationsActivity extends BaseFragment {
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
} else if (i == 17) {
|
||||
} else if (i == 19) {
|
||||
if (reseting) {
|
||||
return;
|
||||
}
|
||||
@ -202,6 +202,13 @@ public class SettingsNotificationsActivity extends BaseFragment {
|
||||
editor.putBoolean("EnableContactJoined", !enabled);
|
||||
editor.commit();
|
||||
listView.invalidateViews();
|
||||
} else if (i == 17) {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
boolean enabled = preferences.getBoolean("EnablePebbleNotifications", false);
|
||||
editor.putBoolean("EnablePebbleNotifications", !enabled);
|
||||
editor.commit();
|
||||
listView.invalidateViews();
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -334,15 +341,15 @@ public class SettingsNotificationsActivity extends BaseFragment {
|
||||
public boolean isEnabled(int i) {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
boolean enabledAll = preferences.getBoolean("EnableAll", true);
|
||||
if (i == 17 || i == 15) {
|
||||
if (i == 19 || i == 15) {
|
||||
return true;
|
||||
}
|
||||
return !(i != 1 && !enabledAll && i != 13) && (i > 0 && i < 5 || i > 5 && i < 10 || i > 10 && i < 14);
|
||||
return !(i != 1 && !enabledAll && i != 13) && (i > 0 && i < 5 || i > 5 && i < 10 || i > 10 && i < 14) || i == 17;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return 18;
|
||||
return 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -378,6 +385,8 @@ public class SettingsNotificationsActivity extends BaseFragment {
|
||||
} else if (i == 14) {
|
||||
textView.setText(LocaleController.getString("Events", R.string.Events));
|
||||
} else if (i == 16) {
|
||||
textView.setText(LocaleController.getString("Pebble", R.string.Pebble));
|
||||
} else if (i == 18) {
|
||||
textView.setText(LocaleController.getString("Reset", R.string.Reset));
|
||||
}
|
||||
} if (type == 1) {
|
||||
@ -433,6 +442,10 @@ public class SettingsNotificationsActivity extends BaseFragment {
|
||||
enabled = preferences.getBoolean("EnableContactJoined", true);
|
||||
textView.setText(LocaleController.getString("ContactJoined", R.string.ContactJoined));
|
||||
divider.setVisibility(View.INVISIBLE);
|
||||
} else if (i == 17) {
|
||||
enabled = preferences.getBoolean("EnablePebbleNotifications", false);
|
||||
textView.setText(LocaleController.getString("Alert", R.string.Alert));
|
||||
divider.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
if (enabled) {
|
||||
checkButton.setImageResource(R.drawable.btn_check_on);
|
||||
@ -480,12 +493,12 @@ public class SettingsNotificationsActivity extends BaseFragment {
|
||||
}
|
||||
textView.setText(LocaleController.getString("Sound", R.string.Sound));
|
||||
divider.setVisibility(View.INVISIBLE);
|
||||
} else if (i == 17) {
|
||||
} else if (i == 19) {
|
||||
textView.setText(LocaleController.getString("ResetAllNotifications", R.string.ResetAllNotifications));
|
||||
textViewDetail.setText(LocaleController.getString("UndoAllCustom", R.string.UndoAllCustom));
|
||||
divider.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
if (i != 17 && !enabledAll) {
|
||||
if (i != 19 && !enabledAll) {
|
||||
view.setEnabled(false);
|
||||
if(android.os.Build.VERSION.SDK_INT >= 11) {
|
||||
textView.setAlpha(0.3f);
|
||||
@ -507,9 +520,9 @@ public class SettingsNotificationsActivity extends BaseFragment {
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int i) {
|
||||
if (i == 0 || i == 5 || i == 10 || i == 14 || i == 16) {
|
||||
if (i == 0 || i == 5 || i == 10 || i == 14 || i == 16 || i == 18) {
|
||||
return 0;
|
||||
} else if (i > 0 && i < 4 || i > 5 && i < 9 || i > 10 && i < 14 || i == 15) {
|
||||
} else if (i > 0 && i < 4 || i > 5 && i < 9 || i > 10 && i < 14 || i == 15 || i == 17) {
|
||||
return 1;
|
||||
} else {
|
||||
return 2;
|
||||
|
@ -249,6 +249,7 @@
|
||||
<string name="AutomaticPhotoDownloadPrivateChats">Private Chats</string>
|
||||
<string name="Events">EVENTS</string>
|
||||
<string name="ContactJoined">Contact joined Telegram</string>
|
||||
<string name="Pebble">PEBBLE</string>
|
||||
|
||||
<!--media view-->
|
||||
<string name="NoMedia">No shared media yet</string>
|
||||
|
Loading…
Reference in New Issue
Block a user