From aa14479e5b2eefdbd654465ce2c9c90b171f6355 Mon Sep 17 00:00:00 2001 From: Bartek Przybylski Date: Sat, 29 Sep 2012 23:17:39 +0200 Subject: [PATCH] removing some obvious warnings as first step to -Werror --- .../datamodel/FileDataStorageManager.java | 1 - .../owncloud/android/datamodel/OCFile.java | 6 ------ src/com/owncloud/android/db/DbHandler.java | 8 +------- .../extensions/ExtensionsListActivity.java | 7 +++++-- .../files/services/FileDownloader.java | 2 -- .../android/files/services/FileUploader.java | 2 -- .../network/AdvancedSslSocketFactory.java | 2 -- .../operations/RemoteOperationResult.java | 1 - .../syncadapter/ContactSyncAdapter.java | 6 +----- .../ui/activity/AccountSelectActivity.java | 15 ++++++++++---- .../ui/activity/FileDisplayActivity.java | 7 ------- .../android/ui/activity/PinCodeActivity.java | 20 ------------------- .../android/ui/activity/Preferences.java | 4 ---- .../ui/fragment/FileDetailFragment.java | 13 +----------- src/eu/alefzero/webdav/WebdavClient.java | 3 +-- 15 files changed, 20 insertions(+), 77 deletions(-) diff --git a/src/com/owncloud/android/datamodel/FileDataStorageManager.java b/src/com/owncloud/android/datamodel/FileDataStorageManager.java index 244d6d1dd1..161eb083ca 100644 --- a/src/com/owncloud/android/datamodel/FileDataStorageManager.java +++ b/src/com/owncloud/android/datamodel/FileDataStorageManager.java @@ -38,7 +38,6 @@ import android.content.ContentValues; import android.content.OperationApplicationException; import android.database.Cursor; import android.net.Uri; -import android.os.Environment; import android.os.RemoteException; import android.util.Log; diff --git a/src/com/owncloud/android/datamodel/OCFile.java b/src/com/owncloud/android/datamodel/OCFile.java index f50a86fc18..f8208b7fe8 100644 --- a/src/com/owncloud/android/datamodel/OCFile.java +++ b/src/com/owncloud/android/datamodel/OCFile.java @@ -19,13 +19,7 @@ package com.owncloud.android.datamodel; import java.io.File; -import java.net.MalformedURLException; -import java.net.URL; -import com.owncloud.android.files.services.FileDownloader; - - -import android.net.Uri; import android.os.Parcel; import android.os.Parcelable; diff --git a/src/com/owncloud/android/db/DbHandler.java b/src/com/owncloud/android/db/DbHandler.java index 61d56557bf..7c0e343e89 100644 --- a/src/com/owncloud/android/db/DbHandler.java +++ b/src/com/owncloud/android/db/DbHandler.java @@ -1,5 +1,5 @@ /* ownCloud Android client application - * Copyright (C) 2011 Bartek Przybylski + * Copyright (C) 2011-2012 Bartek Przybylski * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,11 +17,6 @@ */ package com.owncloud.android.db; -import java.util.Vector; - -import com.owncloud.android.OwnCloudSession; - - import android.content.ContentValues; import android.content.Context; import android.database.Cursor; @@ -38,7 +33,6 @@ public class DbHandler { private SQLiteDatabase mDB; private OpenerHepler mHelper; private final String mDatabaseName = "ownCloud"; - private final String TABLE_SESSIONS = "sessions"; private final int mDatabaseVersion = 1; private final String TABLE_INSTANT_UPLOAD = "instant_upload"; diff --git a/src/com/owncloud/android/extensions/ExtensionsListActivity.java b/src/com/owncloud/android/extensions/ExtensionsListActivity.java index 44aa819c13..d2887a0441 100644 --- a/src/com/owncloud/android/extensions/ExtensionsListActivity.java +++ b/src/com/owncloud/android/extensions/ExtensionsListActivity.java @@ -2,7 +2,6 @@ package com.owncloud.android.extensions; import java.util.HashMap; import java.util.LinkedList; -import java.util.Vector; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.methods.GetMethod; @@ -14,7 +13,6 @@ import com.owncloud.android.utils.OwnCloudVersion; import android.R; -import android.app.Activity; import android.app.ListActivity; import android.os.Bundle; import android.os.Handler; @@ -115,20 +113,25 @@ public class ExtensionsListActivity extends ListActivity { return mDescription; } + @SuppressWarnings("unused") public String getIcon() { return mIcon; } + @SuppressWarnings("unused") public String getDownload() { return mDownload; } + @SuppressWarnings("unused") public String getPlayId() { return mPlayId; } + @SuppressWarnings("unused") public OwnCloudVersion getVersion() { return mVersion; } } + } diff --git a/src/com/owncloud/android/files/services/FileDownloader.java b/src/com/owncloud/android/files/services/FileDownloader.java index 59d5daaa5b..a1881df639 100644 --- a/src/com/owncloud/android/files/services/FileDownloader.java +++ b/src/com/owncloud/android/files/services/FileDownloader.java @@ -5,14 +5,12 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; -import com.owncloud.android.authenticator.AccountAuthenticator; import com.owncloud.android.db.ProviderMeta.ProviderTableMeta; import eu.alefzero.webdav.OnDatatransferProgressListener; import com.owncloud.android.network.OwnCloudClientUtils; import android.accounts.Account; -import android.accounts.AccountManager; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; diff --git a/src/com/owncloud/android/files/services/FileUploader.java b/src/com/owncloud/android/files/services/FileUploader.java index 1091691773..ad8356d493 100644 --- a/src/com/owncloud/android/files/services/FileUploader.java +++ b/src/com/owncloud/android/files/services/FileUploader.java @@ -17,7 +17,6 @@ import com.owncloud.android.operations.RemoteOperationResult; import com.owncloud.android.operations.UploadFileOperation; import com.owncloud.android.utils.OwnCloudVersion; -import eu.alefzero.webdav.ChunkFromFileChannelRequestEntity; import eu.alefzero.webdav.OnDatatransferProgressListener; import com.owncloud.android.network.OwnCloudClientUtils; @@ -38,7 +37,6 @@ import android.os.Process; import android.util.Log; import android.widget.RemoteViews; -import com.owncloud.android.AccountUtils; import com.owncloud.android.R; import eu.alefzero.webdav.WebdavClient; diff --git a/src/com/owncloud/android/network/AdvancedSslSocketFactory.java b/src/com/owncloud/android/network/AdvancedSslSocketFactory.java index c6f1b1688a..755888f73e 100644 --- a/src/com/owncloud/android/network/AdvancedSslSocketFactory.java +++ b/src/com/owncloud/android/network/AdvancedSslSocketFactory.java @@ -25,7 +25,6 @@ import java.net.Socket; import java.net.SocketAddress; import java.net.UnknownHostException; import java.security.cert.X509Certificate; -import java.util.Enumeration; import javax.net.SocketFactory; import javax.net.ssl.SSLContext; @@ -33,7 +32,6 @@ import javax.net.ssl.SSLException; import javax.net.ssl.SSLHandshakeException; import javax.net.ssl.SSLPeerUnverifiedException; import javax.net.ssl.SSLSession; -import javax.net.ssl.SSLSessionContext; import javax.net.ssl.SSLSocket; import org.apache.commons.httpclient.ConnectTimeoutException; diff --git a/src/com/owncloud/android/operations/RemoteOperationResult.java b/src/com/owncloud/android/operations/RemoteOperationResult.java index eb895ca174..b95f734075 100644 --- a/src/com/owncloud/android/operations/RemoteOperationResult.java +++ b/src/com/owncloud/android/operations/RemoteOperationResult.java @@ -25,7 +25,6 @@ import java.net.SocketTimeoutException; import java.net.UnknownHostException; import javax.net.ssl.SSLException; -import javax.net.ssl.SSLPeerUnverifiedException; import org.apache.commons.httpclient.ConnectTimeoutException; import org.apache.commons.httpclient.HttpException; diff --git a/src/com/owncloud/android/syncadapter/ContactSyncAdapter.java b/src/com/owncloud/android/syncadapter/ContactSyncAdapter.java index 2508dcd68a..df69bd727e 100644 --- a/src/com/owncloud/android/syncadapter/ContactSyncAdapter.java +++ b/src/com/owncloud/android/syncadapter/ContactSyncAdapter.java @@ -3,14 +3,11 @@ package com.owncloud.android.syncadapter; import java.io.FileInputStream; import java.io.IOException; -import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpPut; import org.apache.http.entity.ByteArrayEntity; import com.owncloud.android.AccountUtils; import com.owncloud.android.authenticator.AccountAuthenticator; -import com.owncloud.android.db.ProviderMeta; -import com.owncloud.android.db.ProviderMeta.ProviderTableMeta; import android.accounts.Account; import android.accounts.AccountManager; @@ -24,7 +21,6 @@ import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.provider.ContactsContract; -import android.util.Log; public class ContactSyncAdapter extends AbstractOwnCloudSyncAdapter { private String mAddrBookUri; @@ -53,7 +49,7 @@ public class ContactSyncAdapter extends AbstractOwnCloudSyncAdapter { byte[] b = new byte[f.available()]; f.read(b); query.setEntity(new ByteArrayEntity(b)); - HttpResponse response = fireRawRequest(query); + fireRawRequest(query); } catch (IOException e) { e.printStackTrace(); return; diff --git a/src/com/owncloud/android/ui/activity/AccountSelectActivity.java b/src/com/owncloud/android/ui/activity/AccountSelectActivity.java index 50f76258b9..2942ebb5b4 100644 --- a/src/com/owncloud/android/ui/activity/AccountSelectActivity.java +++ b/src/com/owncloud/android/ui/activity/AccountSelectActivity.java @@ -19,9 +19,7 @@ import android.view.ContextMenu; import android.view.View; import android.view.ViewGroup; import android.view.ContextMenu.ContextMenuInfo; -import android.widget.AdapterView; import android.widget.AdapterView.AdapterContextMenuInfo; -import android.widget.AdapterView.OnItemLongClickListener; import android.widget.CheckedTextView; import android.widget.ListView; import android.widget.SimpleAdapter; @@ -40,6 +38,8 @@ import com.owncloud.android.R; public class AccountSelectActivity extends SherlockListActivity implements AccountManagerCallback { + private static final String TAG = "AccountSelectActivity"; + private static final String PREVIOUS_ACCOUNT_KEY = "ACCOUNT"; private final Handler mHandler = new Handler(); @@ -124,13 +124,20 @@ public class AccountSelectActivity extends SherlockListActivity implements return false; } + @SuppressWarnings("unchecked") @Override public boolean onContextItemSelected(android.view.MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item .getMenuInfo(); int index = info.position; - HashMap map = (HashMap) getListAdapter() - .getItem(index); + HashMap map = null; + try { + map = (HashMap) getListAdapter().getItem(index); + } catch (ClassCastException e) { + Log.wtf(TAG, "getitem(index) from list adapter did not return hashmap, bailing out"); + return false; + } + String accountName = map.get("NAME"); AccountManager am = (AccountManager) getSystemService(ACCOUNT_SERVICE); Account accounts[] = am diff --git a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java index 1adbb1b0eb..fb310ecc97 100644 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -21,7 +21,6 @@ package com.owncloud.android.ui.activity; import java.io.File; import android.accounts.Account; -import android.accounts.AccountManager; import android.app.AlertDialog; import android.app.ProgressDialog; import android.app.AlertDialog.Builder; @@ -40,7 +39,6 @@ import android.content.res.Resources.NotFoundException; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; -import android.os.Environment; import android.os.Handler; import android.preference.PreferenceManager; import android.provider.MediaStore; @@ -65,10 +63,7 @@ import com.owncloud.android.authenticator.AccountAuthenticator; import com.owncloud.android.datamodel.DataStorageManager; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; -import com.owncloud.android.db.ProviderMeta.ProviderTableMeta; -import com.owncloud.android.files.OwnCloudFileObserver; import com.owncloud.android.files.services.FileDownloader; -import com.owncloud.android.files.services.FileObserverService; import com.owncloud.android.files.services.FileUploader; import com.owncloud.android.network.OwnCloudClientUtils; import com.owncloud.android.syncadapter.FileSyncService; @@ -637,13 +632,11 @@ public class FileDisplayActivity extends SherlockFragmentActivity implements private class DirectoryCreator implements Runnable { private String mTargetPath; private Account mAccount; - private AccountManager mAm; private Handler mHandler; public DirectoryCreator(String targetPath, Account account, Handler handler) { mTargetPath = targetPath; mAccount = account; - mAm = (AccountManager) getSystemService(ACCOUNT_SERVICE); mHandler = handler; } diff --git a/src/com/owncloud/android/ui/activity/PinCodeActivity.java b/src/com/owncloud/android/ui/activity/PinCodeActivity.java index 4cc224a52b..c545fb227b 100644 --- a/src/com/owncloud/android/ui/activity/PinCodeActivity.java +++ b/src/com/owncloud/android/ui/activity/PinCodeActivity.java @@ -27,25 +27,19 @@ import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; -import android.graphics.Typeface; import android.os.Bundle; -import android.os.Handler; import android.preference.PreferenceManager; import android.text.Editable; -import android.text.InputType; import android.text.TextWatcher; -import android.text.method.PasswordTransformationMethod; import android.view.KeyEvent; import android.view.View; import android.view.View.OnClickListener; import android.view.View.OnFocusChangeListener; import android.view.View.OnKeyListener; -import android.view.ViewGroup; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; - public class PinCodeActivity extends SherlockFragmentActivity { @@ -238,8 +232,6 @@ public class PinCodeActivity extends SherlockFragmentActivity { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { - // TODO Auto-generated method stub - if (keyCode == KeyEvent.KEYCODE_DEL && bChange) { mText1.setText(""); @@ -260,8 +252,6 @@ public class PinCodeActivity extends SherlockFragmentActivity { @Override public void onFocusChange(View v, boolean hasFocus) { - // TODO Auto-generated method stub - mText2.setCursorVisible(true); if (mText1.getText().toString().equals("")){ mText2.setSelected(false); @@ -305,8 +295,6 @@ public class PinCodeActivity extends SherlockFragmentActivity { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { - // TODO Auto-generated method stub - if (keyCode == KeyEvent.KEYCODE_DEL && bChange) { mText2.requestFocus(); if (!confirmingPinCode) @@ -326,7 +314,6 @@ public class PinCodeActivity extends SherlockFragmentActivity { @Override public void onFocusChange(View v, boolean hasFocus) { - // TODO Auto-generated method stub mText3.setCursorVisible(true); if (mText1.getText().toString().equals("")){ mText3.setSelected(false); @@ -411,8 +398,6 @@ public class PinCodeActivity extends SherlockFragmentActivity { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { - // TODO Auto-generated method stub - if (keyCode == KeyEvent.KEYCODE_DEL && bChange) { mText3.requestFocus(); if (!confirmingPinCode) @@ -431,8 +416,6 @@ public class PinCodeActivity extends SherlockFragmentActivity { @Override public void onFocusChange(View v, boolean hasFocus) { - // TODO Auto-generated method stub - mText4.setCursorVisible(true); if (mText1.getText().toString().equals("")){ @@ -503,7 +486,6 @@ public class PinCodeActivity extends SherlockFragmentActivity { @Override public void onClick(DialogInterface dialog, int which) { - // TODO Auto-generated method stub(""); return; } @@ -549,7 +531,6 @@ public class PinCodeActivity extends SherlockFragmentActivity { @Override public void onClick(DialogInterface dialog, int which) { - // TODO Auto-generated method stub(""); return; } @@ -583,7 +564,6 @@ public class PinCodeActivity extends SherlockFragmentActivity { @Override public void onClick(DialogInterface dialog, int which) { - // TODO Auto-generated method stub(""); finish(); return; } diff --git a/src/com/owncloud/android/ui/activity/Preferences.java b/src/com/owncloud/android/ui/activity/Preferences.java index ca134169e0..9dfce13830 100644 --- a/src/com/owncloud/android/ui/activity/Preferences.java +++ b/src/com/owncloud/android/ui/activity/Preferences.java @@ -19,8 +19,6 @@ package com.owncloud.android.ui.activity; import java.util.Vector; -import android.accounts.Account; -import android.accounts.AccountManager; import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; @@ -36,9 +34,7 @@ import com.actionbarsherlock.app.ActionBar; import com.actionbarsherlock.app.SherlockPreferenceActivity; import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.MenuItem; -import com.owncloud.android.AccountUtils; import com.owncloud.android.OwnCloudSession; -import com.owncloud.android.authenticator.AccountAuthenticator; import com.owncloud.android.db.DbHandler; import com.owncloud.android.R; diff --git a/src/com/owncloud/android/ui/fragment/FileDetailFragment.java b/src/com/owncloud/android/ui/fragment/FileDetailFragment.java index 4772ddf42c..9dfb4508bc 100644 --- a/src/com/owncloud/android/ui/fragment/FileDetailFragment.java +++ b/src/com/owncloud/android/ui/fragment/FileDetailFragment.java @@ -35,7 +35,6 @@ import org.apache.http.protocol.HTTP; import org.apache.jackrabbit.webdav.client.methods.DavMethodBase; import org.apache.jackrabbit.webdav.client.methods.DeleteMethod; import org.apache.jackrabbit.webdav.client.methods.PropFindMethod; -import org.json.JSONException; import org.json.JSONObject; import android.accounts.Account; @@ -79,7 +78,6 @@ import com.owncloud.android.authenticator.AccountAuthenticator; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.files.services.FileDownloader; -import com.owncloud.android.files.services.FileObserverService; import com.owncloud.android.files.services.FileUploader; import com.owncloud.android.network.OwnCloudClientUtils; import com.owncloud.android.ui.activity.FileDetailActivity; @@ -649,6 +647,7 @@ public class FileDetailFragment extends SherlockFragment implements // this is a temporary class for sharing purposes, it need to be replaced in transfer service + @SuppressWarnings("unused") private class ShareRunnable implements Runnable { private String mPath; @@ -741,17 +740,7 @@ public class FileDetailFragment extends SherlockFragment implements String uri = am.getUserData(account, AccountAuthenticator.KEY_OC_BASE_URL) + SHARED_PATH + token; Log.d("Actions:shareFile ok", "url: " + uri); - } catch (HttpException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (JSONException e) { - // TODO Auto-generated catch block - e.printStackTrace(); } catch (Exception e) { - // TODO Auto-generated catch block e.printStackTrace(); } diff --git a/src/eu/alefzero/webdav/WebdavClient.java b/src/eu/alefzero/webdav/WebdavClient.java index 2e3ef874bb..f3aca3e53e 100644 --- a/src/eu/alefzero/webdav/WebdavClient.java +++ b/src/eu/alefzero/webdav/WebdavClient.java @@ -22,7 +22,6 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.util.Random; import org.apache.commons.httpclient.Credentials; import org.apache.commons.httpclient.HttpClient; @@ -102,12 +101,12 @@ public class WebdavClient extends HttpClient { mDataTransferListener.transferProgress(readResult); fos.write(bytes, 0, readResult); } + fos.close(); ret = true; } else { exhaustResponse(get.getResponseBodyAsStream()); } Log.e(TAG, "Download of " + remoteFilePath + " to " + targetFile + " finished with HTTP status " + status + (!ret?"(FAIL)":"")); - } catch (Exception e) { logException(e, "dowloading " + remoteFilePath);