Merge pull request #177 from l3d00m/develop

Fix for #142 and #130, random patches
This commit is contained in:
Moez Bhatti
2015-09-24 23:27:33 -04:00
35 changed files with 124 additions and 123 deletions
@@ -72,11 +72,11 @@ public abstract class ElementTimeImpl implements ElementTime {
String[] beginTimeStringList = mSmilElement.getAttribute("begin").split(";");
// TODO: Check other constraints on parsed values, e.g., "single, non-negative offset values
ArrayList<Time> beginTimeList = new ArrayList<Time>();
ArrayList<Time> beginTimeList = new ArrayList<>();
// Initialize Time instances and add them to Vector
for (int i = 0; i < beginTimeStringList.length; i++) {
for (String aBeginTimeStringList : beginTimeStringList) {
try {
beginTimeList.add(new TimeImpl(beginTimeStringList[i], getBeginConstraints()));
beginTimeList.add(new TimeImpl(aBeginTimeStringList, getBeginConstraints()));
} catch (IllegalArgumentException e) {
// Ignore badly formatted times
}
@@ -121,15 +121,15 @@ public abstract class ElementTimeImpl implements ElementTime {
}
public TimeList getEnd() {
ArrayList<Time> endTimeList = new ArrayList<Time>();
ArrayList<Time> endTimeList = new ArrayList<>();
String[] endTimeStringList = mSmilElement.getAttribute("end").split(";");
int len = endTimeStringList.length;
if (!((len == 1) && (endTimeStringList[0].length() == 0))) { // Ensure the end field is set.
// Initialize Time instances and add them to Vector
for (int i = 0; i < len; i++) {
for (String anEndTimeStringList : endTimeStringList) {
try {
endTimeList.add(new TimeImpl(endTimeStringList[i],
endTimeList.add(new TimeImpl(anEndTimeStringList,
getEndConstraints()));
} catch (IllegalArgumentException e) {
// Ignore badly formatted times
@@ -245,7 +245,7 @@ public abstract class ElementTimeImpl implements ElementTime {
*/
return FILL_AUTO;
} else {
return ((ElementTimeImpl) parent).getFillDefault();
return parent.getFillDefault();
}
}
}
@@ -156,28 +156,29 @@ public class SmilDocumentImpl extends DocumentImpl implements SMILDocument, Docu
public Element createElement(String tagName) throws DOMException {
// Find the appropriate class for this element
tagName = tagName.toLowerCase();
if (tagName.equals("text") ||
tagName.equals("img") ||
tagName.equals("video")) {
return new SmilRegionMediaElementImpl(this, tagName);
} else if (tagName.equals("audio")) {
return new SmilMediaElementImpl(this, tagName);
} else if (tagName.equals("layout")) {
return new SmilLayoutElementImpl(this, tagName);
} else if (tagName.equals("root-layout")) {
return new SmilRootLayoutElementImpl(this, tagName);
} else if (tagName.equals("region")) {
return new SmilRegionElementImpl(this, tagName);
} else if (tagName.equals("ref")) {
return new SmilRefElementImpl(this, tagName);
} else if (tagName.equals("par")) {
return new SmilParElementImpl(this, tagName);
} else if (tagName.equals("vcard")) {
return new SmilRegionMediaElementImpl(this, tagName);
} else {
// This includes also the structural nodes SMIL,
// HEAD, BODY, for which no specific types are defined.
return new SmilElementImpl(this, tagName);
switch (tagName) {
case "text":
case "img":
case "video":
return new SmilRegionMediaElementImpl(this, tagName);
case "audio":
return new SmilMediaElementImpl(this, tagName);
case "layout":
return new SmilLayoutElementImpl(this, tagName);
case "root-layout":
return new SmilRootLayoutElementImpl(this, tagName);
case "region":
return new SmilRegionElementImpl(this, tagName);
case "ref":
return new SmilRefElementImpl(this, tagName);
case "par":
return new SmilParElementImpl(this, tagName);
case "vcard":
return new SmilRegionMediaElementImpl(this, tagName);
default:
// This includes also the structural nodes SMIL,
// HEAD, BODY, for which no specific types are defined.
return new SmilElementImpl(this, tagName);
}
}
@@ -44,7 +44,7 @@ public class SmilParElementImpl extends SmilElementImpl implements SMILParElemen
*/
TimeList beginTimeList = super.getBegin();
if (beginTimeList.getLength() > 1) {
ArrayList<Time> singleTimeContainer = new ArrayList<Time>();
ArrayList<Time> singleTimeContainer = new ArrayList<>();
singleTimeContainer.add(beginTimeList.item(0));
beginTimeList = new TimeListImpl(singleTimeContainer);
}
@@ -46,7 +46,7 @@ public class SmilPlayer implements Runnable {
private static final boolean LOCAL_LOGV = false;
private static final int TIMESLICE = 200;
private static enum SmilPlayerState {
private enum SmilPlayerState {
INITIALIZED,
PLAYING,
PLAYED,
@@ -54,7 +54,7 @@ public class SmilPlayer implements Runnable {
STOPPED,
}
private static enum SmilPlayerAction {
private enum SmilPlayerAction {
NO_ACTIVE_ACTION,
RELOAD,
STOP,
@@ -88,7 +88,7 @@ public class SmilPlayer implements Runnable {
private static ArrayList<TimelineEntry> getParTimeline(
ElementParallelTimeContainer par, double offset, double maxOffset) {
ArrayList<TimelineEntry> timeline = new ArrayList<TimelineEntry>();
ArrayList<TimelineEntry> timeline = new ArrayList<>();
// Set my begin at first
TimeList myBeginList = par.getBegin();
@@ -145,7 +145,7 @@ public class SmilPlayer implements Runnable {
private static ArrayList<TimelineEntry> getSeqTimeline(
ElementSequentialTimeContainer seq, double offset, double maxOffset) {
ArrayList<TimelineEntry> timeline = new ArrayList<TimelineEntry>();
ArrayList<TimelineEntry> timeline = new ArrayList<>();
double orgOffset = offset;
// Set my begin at first
@@ -211,7 +211,7 @@ public class SmilPlayer implements Runnable {
return getSeqTimeline((ElementSequentialTimeContainer) element, offset, maxOffset);
} else {
// Not ElementTimeContainer here
ArrayList<TimelineEntry> timeline = new ArrayList<TimelineEntry>();
ArrayList<TimelineEntry> timeline = new ArrayList<>();
TimeList beginList = element.getBegin();
for (int i = 0; i < beginList.getLength(); ++i) {
@@ -301,7 +301,7 @@ public class SmilPlayer implements Runnable {
mAllEntries = getTimeline(mRoot, 0, Long.MAX_VALUE);
mMediaTimeUpdatedEvent = ((DocumentEvent) mRoot).createEvent("Event");
mMediaTimeUpdatedEvent.initEvent(MEDIA_TIME_UPDATED_EVENT, false, false);
mActiveElements = new ArrayList<ElementTime>();
mActiveElements = new ArrayList<>();
}
public synchronized void play() {
@@ -529,7 +529,7 @@ public class SmilPlayer implements Runnable {
}
private void stopCurrentSlide() {
HashSet<TimelineEntry> skippedEntries = new HashSet<TimelineEntry>();
HashSet<TimelineEntry> skippedEntries = new HashSet<>();
int totalEntries = mAllEntries.size();
for (int i = mCurrentElement; i < totalEntries; i++) {
// Stop any started entries, and skip the not started entries until
@@ -64,7 +64,7 @@ public class EndlessJabberInterface {
editor.putString("InterfaceClass", concreteImplementation.getName());
editor.putBoolean("SendSMS", sendSMS);
editor.putBoolean("SendMMS", sendMMS);
editor.commit();
editor.apply();
SendInfoToEndlessJabber(context);
}
@@ -74,7 +74,7 @@ public class EndlessJabberInterface {
public static void DisableIntegration(Context context, Class nameOfImplementation) {
SharedPreferences.Editor editor = context.getSharedPreferences("EndlessJabberSDK", Context.MODE_PRIVATE).edit();
editor.clear();
editor.commit();
editor.apply();
SendInfoToEndlessJabber(context);
}
@@ -61,6 +61,10 @@ public class ConversationPrefsHelper {
return getBoolean(SettingsFragment.NOTIFICATION_CALL_BUTTON, false);
}
public boolean getDimissedReadEnabled() {
return getBoolean(SettingsFragment.DISMISSED_READ, false);
}
public void putString(String key, String value) {
mConversationPrefs.edit().putString(key, value).apply();
}
@@ -73,7 +73,7 @@ public class CacheManager {
// ignore.
}
if (n != 0) return;
pref.edit().putInt(KEY_CACHE_UP_TO_DATE, 1).commit();
pref.edit().putInt(KEY_CACHE_UP_TO_DATE, 1).apply();
clear(context);
}
@@ -137,8 +137,8 @@ public class ImageCacheService {
public static final long crc64Long(byte[] buffer) {
long crc = INITIALCRC;
for (int k = 0, n = buffer.length; k < n; ++k) {
crc = sCrcTable[(((int) crc) ^ buffer[k]) & 0xff] ^ (crc >> 8);
for (byte aBuffer : buffer) {
crc = sCrcTable[(((int) crc) ^ aBuffer) & 0xff] ^ (crc >> 8);
}
return crc;
}
@@ -81,7 +81,7 @@ public class ThumbnailManager extends BackgroundLoaderManager {
public ThumbnailManager(final Context context) {
super(context);
mThumbnailCache = new SimpleCache<Uri, Bitmap>(8, 16, 0.75f, true);
mThumbnailCache = new SimpleCache<>(8, 16, 0.75f, true);
mContext = context;
mEmptyImageBitmap = BitmapFactory.decodeResource(context.getResources(),
@@ -1247,7 +1247,7 @@ public class ExifInterface {
if (l == null || l.length <= 0) {
return null;
}
return new Long(l[0]);
return Long.valueOf(l[0]);
}
/**
@@ -1266,7 +1266,7 @@ public class ExifInterface {
if (l == null || l.length <= 0) {
return null;
}
return new Integer(l[0]);
return Integer.valueOf(l[0]);
}
/**
@@ -1285,7 +1285,7 @@ public class ExifInterface {
if (l == null || l.length <= 0) {
return null;
}
return new Byte(l[0]);
return Byte.valueOf(l[0]);
}
/**
@@ -474,6 +474,7 @@ public class NotificationManager {
.addAction(R.drawable.ic_accept, sRes.getString(R.string.read), readPI)
.extend(WearableIntentReceiver.getSingleConversationExtender(context, message.mContact, message.mAddress, threadId))
.setDeleteIntent(seenPI);
if (conversationPrefs.getDimissedReadEnabled()){builder.setDeleteIntent(readPI);}
if (conversationPrefs.getCallButtonEnabled()) {
Intent callIntent = new Intent(Intent.ACTION_CALL);
@@ -2,7 +2,6 @@ package com.moez.QKSMS.ui.conversationlist;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
@@ -33,7 +33,6 @@ import com.moez.QKSMS.transaction.SmsHelper;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -95,7 +94,7 @@ public class DeliveryReportHelper {
public List<DeliveryReportItem> getListItems() {
List<DeliveryReportItem> items = getReportItems();
if (items == null) {
items = new ArrayList<DeliveryReportItem>(1);
items = new ArrayList<>(1);
items.add(new DeliveryReportItem("", mContext.getString(R.string.status_none), null));
Log.w(LOG_TAG, "cursor == null");
}
@@ -191,15 +190,12 @@ public class DeliveryReportHelper {
private static MmsReportStatus queryStatusByRecipient(
Map<String, MmsReportStatus> status, String recipient) {
Set<String> recipientSet = status.keySet();
Iterator<String> iterator = recipientSet.iterator();
while (iterator.hasNext()) {
String r = iterator.next();
for (String r : recipientSet) {
if (SmsHelper.isEmailAddress(recipient)) {
if (TextUtils.equals(r, recipient)) {
return status.get(r);
}
}
else if (PhoneNumberUtils.compare(r, recipient)) {
} else if (PhoneNumberUtils.compare(r, recipient)) {
return status.get(r);
}
}
@@ -235,7 +235,7 @@ public class QKDialog extends DialogFragment {
}
public QKDialog buildMenu(final OnItemClickListener onItemClickListener) {
ArrayAdapter adapter = new ArrayAdapter<String>(mContext, R.layout.list_item_simple, mMenuItems);
ArrayAdapter adapter = new ArrayAdapter<>(mContext, R.layout.list_item_simple, mMenuItems);
ListView listView = new ListView(mContext);
listView.setAdapter(adapter);
listView.setDivider(null);
@@ -256,7 +256,7 @@ public class QKDialog extends DialogFragment {
}
public QKDialog setItems(String[] items, final OnItemClickListener onClickListener) {
ArrayAdapter adapter = new ArrayAdapter<String>(mContext, R.layout.list_item_simple, items);
ArrayAdapter adapter = new ArrayAdapter<>(mContext, R.layout.list_item_simple, items);
ListView listView = new ListView(mContext);
listView.setAdapter(adapter);
listView.setDivider(null);
@@ -301,7 +301,7 @@ public class QKDialogFragment extends DialogFragment {
}
public QKDialogFragment setItems(String[] items) {
ArrayAdapter adapter = new ArrayAdapter<String>(mContext, R.layout.list_item_simple, items);
ArrayAdapter adapter = new ArrayAdapter<>(mContext, R.layout.list_item_simple, items);
ListView listView = new ListView(mContext);
listView.setAdapter(adapter);
listView.setDivider(null);
@@ -36,7 +36,6 @@ import com.google.android.mms.pdu_alt.NotificationInd;
import com.google.android.mms.pdu_alt.PduHeaders;
import com.google.android.mms.pdu_alt.PduPersister;
import com.google.android.mms.pdu_alt.RetrieveConf;
import com.google.android.mms.pdu_alt.SendReq;
import com.moez.QKSMS.QKSMSApp;
import com.moez.QKSMS.R;
import com.moez.QKSMS.data.Contact;
@@ -383,7 +382,7 @@ public class MessageItem {
// Use constant string for outgoing messages
mContact = mAddress =
mContext.getString(R.string.messagelist_sender_self);
timestamp = msg == null ? 0 : ((SendReq) msg).getDate() * 1000L;
timestamp = msg == null ? 0 : msg.getDate() * 1000L;
}
SlideModel slide = mSlideshow == null ? null : mSlideshow.get(0);
@@ -150,7 +150,7 @@ public class SlideshowActivity extends QKActivity implements EventListener {
@Override
public void onCreate(Bundle icicle) {
// Play slide-show in full-screen mode.
requestWindowFeature(Window.FEATURE_NO_TITLE);
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(icicle);
mHandler = new Handler();
@@ -142,6 +142,7 @@ public class SettingsFragment extends PreferenceFragment implements
public static final String MMS_CONTACT_SUPPORT = "pref_key_mms_contact_support";
public static final String SIMPLE_PREFS = "pref_key_simple";
public static final String DONATE = "pref_key_donate";
public static final String DISMISSED_READ = "pref_key_dismiss_read";
/**
* @deprecated
*/
@@ -482,7 +483,10 @@ public class SettingsFragment extends PreferenceFragment implements
case DELAY_DURATION:
try {
int duration = Integer.parseInt((String) newValue);
if (duration < 1 || duration > 30) throw new Exception("Duration out of bounds");
if (duration < 1 || duration > 30)
throw new Exception("Duration out of bounds");
} catch (Exception e) {
Toast.makeText(mContext, R.string.delayed_duration_bounds_error, Toast.LENGTH_SHORT).show();
}
@@ -194,18 +194,26 @@ public class ComposeView extends LinearLayout implements View.OnClickListener, L
switch (Integer.parseInt(mPrefs.getString(SettingsFragment.ENTER_BUTTON, "0"))) {
case 0: // emoji
break;
case 1: // return
case 1: // new line
mReplyText.setInputType(InputType.TYPE_CLASS_TEXT |
InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE |
InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
InputType.TYPE_TEXT_FLAG_CAP_SENTENCES |
InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE);
mReplyText.setSingleLine(false);
break;
case 2: // send
mReplyText.setInputType(
mReplyText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
mReplyText.setInputType(InputType.TYPE_CLASS_TEXT |
InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
mReplyText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI |
EditorInfo.IME_ACTION_SEND);
mReplyText.setSingleLine(false);
mReplyText.setOnKeyListener(new OnKeyListener() { //Workaround because ACTION_SEND does not support multiline mode
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == 66) {
sendSms();
return true;
}
return false;
}});
break;
}
@@ -228,18 +236,6 @@ public class ComposeView extends LinearLayout implements View.OnClickListener, L
}
});
mReplyText.setOnEditorActionListener(new android.widget.TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(android.widget.TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEND) {
sendSms();
return true;
}
return false;
}
});
mProgressAnimator = new ValueAnimator();
mProgressAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
mProgressAnimator.setDuration(mDelayDuration);
@@ -460,7 +456,9 @@ public class ComposeView extends LinearLayout implements View.OnClickListener, L
}
long threadId = mConversation != null ? mConversation.getThreadId() : 0;
sendTransaction.sendNewMessage(message, threadId);
if (!message.toString().equals("")) {
sendTransaction.sendNewMessage(message, threadId);
}
NotificationManager.update(mContext);
if (mConversationLegacy != null) {
@@ -53,7 +53,7 @@ public class DemoConversationCursorLoader extends Loader<Cursor> {
ArrayList<MessageData> candidates = new ArrayList<>();
if (THREAD_ID_WELCOME_SCREEN == mThreadId) {
candidates = new ArrayList<MessageData>();
candidates = new ArrayList<>();
long time = System.currentTimeMillis() - 50000;
candidates.add(new MessageData(
"sms", 0, mThreadId, "QKSMS",
@@ -176,6 +176,6 @@ public class WelcomeActivity extends QKActivity implements ViewPager.OnPageChang
SharedPreferences.Editor prefs = PreferenceManager.getDefaultSharedPreferences(this).edit();
prefs.putBoolean(SettingsFragment.WELCOME_SEEN, true);
prefs.commit();
prefs.apply();
}
}