code cleanup & small fixes
This commit is contained in:
parent
6d24ce7a18
commit
226d45a136
22 changed files with 42 additions and 49 deletions
|
@ -792,7 +792,7 @@ public class Message extends AbstractEntity implements AvatarService.Avatarable
|
|||
if (this.transferable != null) {
|
||||
fileParams.size = this.transferable.getFileSize();
|
||||
}
|
||||
String parts[] = body == null ? new String[0] : body.split("\\|");
|
||||
String[] parts = body == null ? new String[0] : body.split("\\|");
|
||||
switch (parts.length) {
|
||||
case 1:
|
||||
try {
|
||||
|
|
|
@ -601,7 +601,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
|
|||
continue;
|
||||
}
|
||||
|
||||
String updateArgs[] = {
|
||||
String[] updateArgs = {
|
||||
newJid,
|
||||
cursor.getString(cursor.getColumnIndex(Conversation.UUID)),
|
||||
};
|
||||
|
@ -624,7 +624,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
|
|||
continue;
|
||||
}
|
||||
|
||||
String updateArgs[] = {
|
||||
String[] updateArgs = {
|
||||
newJid,
|
||||
cursor.getString(cursor.getColumnIndex(Contact.ACCOUNT)),
|
||||
cursor.getString(cursor.getColumnIndex(Contact.JID)),
|
||||
|
@ -653,7 +653,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
|
|||
continue;
|
||||
}
|
||||
|
||||
String updateArgs[] = {
|
||||
String[] updateArgs = {
|
||||
newServer,
|
||||
cursor.getString(cursor.getColumnIndex(Account.UUID)),
|
||||
};
|
||||
|
@ -1052,7 +1052,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
|
|||
public void readRoster(Roster roster) {
|
||||
SQLiteDatabase db = this.getReadableDatabase();
|
||||
Cursor cursor;
|
||||
String args[] = {roster.getAccount().getUuid()};
|
||||
String[] args = {roster.getAccount().getUuid()};
|
||||
cursor = db.query(Contact.TABLENAME, null, Contact.ACCOUNT + "=?", args, null, null, null);
|
||||
while (cursor.moveToNext()) {
|
||||
roster.initContact(Contact.fromCursor(cursor));
|
||||
|
|
|
@ -310,26 +310,26 @@ public class FileBackend {
|
|||
|
||||
public static String getConversationsDirectory(final String type) {
|
||||
if (type.equalsIgnoreCase("null")) {
|
||||
return Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + "Pix-Art Messenger" + "/";
|
||||
return Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "Pix-Art Messenger" + File.separator;
|
||||
} else {
|
||||
return getAppMediaDirectory() + "Pix-Art Messenger" + " " + type + "/";
|
||||
return getAppMediaDirectory() + "Pix-Art Messenger" + " " + type + File.separator;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getAppMediaDirectory() {
|
||||
return Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + "Pix-Art Messenger" + "/Media/";
|
||||
return Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "Pix-Art Messenger" + File.separator + "Media" + File.separator;
|
||||
}
|
||||
|
||||
public static String getBackupDirectory() {
|
||||
return Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + "Pix-Art Messenger" + "/Database/";
|
||||
return Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "Pix-Art Messenger" + File.separator + "Database" + File.separator;
|
||||
}
|
||||
|
||||
public static String getAppLogsDirectory() {
|
||||
return Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + "Pix-Art Messenger" + "/Chats/";
|
||||
return Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "Pix-Art Messenger" + File.separator + "Chats" + File.separator;
|
||||
}
|
||||
|
||||
public static String getAppUpdateDirectory() {
|
||||
return Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + "Pix-Art Messenger" + "/Update/";
|
||||
return Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "Pix-Art Messenger" + File.separator + "Update" + File.separator;
|
||||
}
|
||||
|
||||
private Bitmap resize(final Bitmap originalBitmap, int size) throws IOException {
|
||||
|
@ -731,7 +731,7 @@ public class FileBackend {
|
|||
}
|
||||
|
||||
public Uri getTakePhotoUri() {
|
||||
File file = new File(getTakeFromCameraPath() + "IMG_" + this.fileDateFormat.format(new Date()) + ".jpg");
|
||||
File file = new File(getTakeFromCameraPath() + "IMG_" + fileDateFormat.format(new Date()) + ".jpg");
|
||||
file.getParentFile().mkdirs();
|
||||
return getUriForFile(mXmppConnectionService, file);
|
||||
}
|
||||
|
@ -757,7 +757,7 @@ public class FileBackend {
|
|||
}
|
||||
|
||||
public Uri getTakeVideoUri() {
|
||||
File file = new File(getTakeFromCameraPath() + "VID_" + this.fileDateFormat.format(new Date()) + ".mp4");
|
||||
File file = new File(getTakeFromCameraPath() + "VID_" + fileDateFormat.format(new Date()) + ".mp4");
|
||||
file.getParentFile().mkdirs();
|
||||
return getUriForFile(mXmppConnectionService, file);
|
||||
}
|
||||
|
@ -897,7 +897,7 @@ public class FileBackend {
|
|||
file = new File(getAvatarPath(avatar.getFilename()));
|
||||
avatar.size = file.length();
|
||||
} else {
|
||||
file = new File(mXmppConnectionService.getCacheDir().getAbsolutePath() + "/" + UUID.randomUUID().toString());
|
||||
file = new File(mXmppConnectionService.getCacheDir().getAbsolutePath() + File.separator + UUID.randomUUID().toString());
|
||||
if (file.getParentFile().mkdirs()) {
|
||||
Log.d(Config.LOGTAG, "created cache directory");
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
package de.pixart.messenger.persistance;
|
||||
|
||||
public interface OnPhoneContactsMerged {
|
||||
public void phoneContactsMerged();
|
||||
void phoneContactsMerged();
|
||||
}
|
||||
|
|
|
@ -197,11 +197,7 @@ public class ImportBackupService extends Service {
|
|||
} catch (Exception e) {
|
||||
Throwable throwable = e.getCause();
|
||||
final boolean reasonWasCrypto;
|
||||
if (throwable instanceof BadPaddingException) {
|
||||
reasonWasCrypto = true;
|
||||
} else {
|
||||
reasonWasCrypto = false;
|
||||
}
|
||||
reasonWasCrypto = throwable instanceof BadPaddingException;
|
||||
synchronized (mOnBackupProcessedListeners) {
|
||||
for (OnBackupProcessed l : mOnBackupProcessedListeners) {
|
||||
if (reasonWasCrypto) {
|
||||
|
|
|
@ -768,7 +768,7 @@ public class XmppConnectionService extends Service {
|
|||
private void deleteWebpreviewCache() {
|
||||
long start = SystemClock.elapsedRealtime();
|
||||
try {
|
||||
final String path = getApplicationContext().getCacheDir() + "/" + RICH_LINK_METADATA;
|
||||
final String path = getApplicationContext().getCacheDir() + File.separator + RICH_LINK_METADATA;
|
||||
final Calendar time = Calendar.getInstance();
|
||||
time.add(Calendar.DAY_OF_YEAR, -7);
|
||||
final File directory = new File(path);
|
||||
|
@ -776,18 +776,17 @@ public class XmppConnectionService extends Service {
|
|||
return;
|
||||
}
|
||||
final File[] files = directory.listFiles();
|
||||
if (files == null) {
|
||||
return;
|
||||
}
|
||||
int count = 0;
|
||||
for (File file : files) {
|
||||
Date lastModified = new Date(file.lastModified());
|
||||
if (lastModified.before(time.getTime())) {
|
||||
file.delete();
|
||||
count++;
|
||||
if (files != null) {
|
||||
int count = 0;
|
||||
for (File file : files) {
|
||||
Date lastModified = new Date(file.lastModified());
|
||||
if (lastModified.before(time.getTime())) {
|
||||
file.delete();
|
||||
count++;
|
||||
}
|
||||
}
|
||||
Log.d(Config.LOGTAG, "Deleted " + count + " expired webpreview cache files in " + (SystemClock.elapsedRealtime() - start) + "ms");
|
||||
}
|
||||
Log.d(Config.LOGTAG, "Deleted " + count + " expired webpreview cache files in " + (SystemClock.elapsedRealtime() - start) + "ms");
|
||||
} catch (Exception e) {
|
||||
Log.d(Config.LOGTAG, "Deleted no expired webpreview cache files because of " + e + " in " + (SystemClock.elapsedRealtime() - start) + "ms");
|
||||
}
|
||||
|
|
|
@ -377,7 +377,7 @@ public class ChooseContactActivity extends AbstractSearchableListItemActivity im
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
ScanActivity.onRequestPermissionResult(this, requestCode, grantResults);
|
||||
}
|
||||
|
||||
|
|
|
@ -1583,7 +1583,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
if (grantResults.length > 0) {
|
||||
if (allGranted(grantResults)) {
|
||||
switch (requestCode) {
|
||||
|
|
|
@ -337,7 +337,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
UriHandlerActivity.onRequestPermissionResult(this, requestCode, grantResults);
|
||||
if (grantResults.length > 0) {
|
||||
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
|
|
|
@ -1497,7 +1497,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
if (grantResults.length > 0) {
|
||||
if (allGranted(grantResults)) {
|
||||
switch (requestCode) {
|
||||
|
|
|
@ -210,7 +210,7 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
if (grantResults.length > 0) {
|
||||
if (allGranted(grantResults)) {
|
||||
switch (requestCode) {
|
||||
|
|
|
@ -204,7 +204,7 @@ public abstract class OmemoActivity extends XmppActivity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
|
||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
||||
ScanActivity.onRequestPermissionResult(this, requestCode, grantResults);
|
||||
}
|
||||
}
|
|
@ -367,7 +367,7 @@ public class SettingsActivity extends XmppActivity implements
|
|||
|
||||
private void cleanPrivateFiles(final String type) {
|
||||
try {
|
||||
File dir = new File(getFilesDir().getAbsolutePath(), "/" + type + "/");
|
||||
File dir = new File(getFilesDir().getAbsolutePath(), File.separator + type + File.separator);
|
||||
File[] array = dir.listFiles();
|
||||
if (array != null) {
|
||||
for (int b = 0; b < array.length; b++) {
|
||||
|
|
|
@ -52,7 +52,7 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
|
||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
||||
if (grantResults.length > 0)
|
||||
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
if (requestCode == REQUEST_STORAGE_PERMISSION) {
|
||||
|
|
|
@ -739,7 +739,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
if (grantResults.length > 0) {
|
||||
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
ScanActivity.onRequestPermissionResult(this, requestCode, grantResults);
|
||||
|
|
|
@ -360,7 +360,7 @@ public class UpdaterActivity extends XmppActivity {
|
|||
is = connection.getInputStream();
|
||||
os = new FileOutputStream(file);
|
||||
|
||||
byte data[] = new byte[4096];
|
||||
byte[] data = new byte[4096];
|
||||
long total = 0;
|
||||
int count;
|
||||
while ((count = is.read(data)) != -1) {
|
||||
|
|
|
@ -109,7 +109,7 @@ public class WelcomeActivity extends XmppActivity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
if (grantResults.length > 0) {
|
||||
if (allGranted(grantResults)) {
|
||||
switch (requestCode) {
|
||||
|
|
|
@ -47,7 +47,6 @@ public class GeoHelper {
|
|||
|
||||
private static GeoPoint parseGeoPoint(String body) throws IllegalArgumentException {
|
||||
Matcher matcher = GEO_URI.matcher(body);
|
||||
;
|
||||
if (!matcher.matches()) {
|
||||
throw new IllegalArgumentException("Invalid geo uri");
|
||||
}
|
||||
|
|
|
@ -198,7 +198,6 @@ public class IrregularUnicodeDetector {
|
|||
if (pattern != null) {
|
||||
return pattern;
|
||||
}
|
||||
;
|
||||
pattern = PatternTuple.of(jid);
|
||||
CACHE.put(jid, pattern);
|
||||
return pattern;
|
||||
|
|
|
@ -56,7 +56,7 @@ public class RichPreview {
|
|||
protected Void doInBackground(Void... params) {
|
||||
FileInputStream fis = null;
|
||||
ObjectInputStream is = null;
|
||||
final File file = new File(context.getCacheDir(), RICH_LINK_METADATA + "/" + filename);
|
||||
final File file = new File(context.getCacheDir(), RICH_LINK_METADATA + File.separator + filename);
|
||||
try {
|
||||
fis = new FileInputStream(file);
|
||||
InputStreamReader isr = new InputStreamReader(fis);
|
||||
|
@ -134,7 +134,7 @@ public class RichPreview {
|
|||
}
|
||||
|
||||
private void saveMeta(MetaData metaData, Context context) {
|
||||
final File file = new File(context.getCacheDir(), RICH_LINK_METADATA + "/" + filename);
|
||||
final File file = new File(context.getCacheDir(), RICH_LINK_METADATA + File.separator + filename);
|
||||
file.getParentFile().mkdirs();
|
||||
FileOutputStream fos = null;
|
||||
ObjectOutputStream oos = null;
|
||||
|
|
|
@ -1570,8 +1570,8 @@ public class XmppConnection implements Runnable {
|
|||
if (socket != null) {
|
||||
try {
|
||||
socket.close();
|
||||
} catch (IOException e) {
|
||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": io exception " + e.getMessage() + " during force close");
|
||||
} catch (Exception e) {
|
||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": exception " + e.getMessage() + " during force close");
|
||||
}
|
||||
} else {
|
||||
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": socket was null during force close");
|
||||
|
|
|
@ -448,7 +448,7 @@ public class JingleConnection implements Transferable {
|
|||
if (message.getType() == Message.TYPE_FILE) {
|
||||
String suffix = "";
|
||||
if (!fileNameElement.getContent().isEmpty()) {
|
||||
String parts[] = fileNameElement.getContent().split("/");
|
||||
String[] parts = fileNameElement.getContent().split("/");
|
||||
suffix = parts[parts.length - 1];
|
||||
if (message.getEncryption() == Message.ENCRYPTION_OTR && suffix.endsWith(".otr")) {
|
||||
suffix = suffix.substring(0, suffix.length() - 4);
|
||||
|
|
Reference in a new issue