From: masensio Date: Mon, 18 May 2015 10:59:46 +0000 (+0200) Subject: Remove actionbarsherlock , replace it with Android Support Library (v7) X-Git-Tag: test~8 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/a496f0871713084015aae8e36b7093671907146a?ds=inline Remove actionbarsherlock , replace it with Android Support Library (v7) --- diff --git a/build.gradle b/build.gradle index cd25c8f9..dc43672a 100644 --- a/build.gradle +++ b/build.gradle @@ -27,7 +27,7 @@ dependencies { } android { - compileSdkVersion 19 + compileSdkVersion 21 buildToolsVersion "20.0.0" sourceSets { main { diff --git a/res/values/versioned_styles.xml b/res/values/versioned_styles.xml index c06ec9c3..0c0a7f96 100644 --- a/res/values/versioned_styles.xml +++ b/res/values/versioned_styles.xml @@ -8,12 +8,16 @@ - - diff --git a/src/com/owncloud/android/authentication/AccountAuthenticatorActivity.java b/src/com/owncloud/android/authentication/AccountAuthenticatorActivity.java index 62c8825f..78d95e43 100644 --- a/src/com/owncloud/android/authentication/AccountAuthenticatorActivity.java +++ b/src/com/owncloud/android/authentication/AccountAuthenticatorActivity.java @@ -19,9 +19,7 @@ package com.owncloud.android.authentication; import android.accounts.AccountAuthenticatorResponse; import android.accounts.AccountManager; import android.os.Bundle; - -import com.actionbarsherlock.app.SherlockFragmentActivity; - +import android.support.v7.app.AppCompatActivity; /* * Base class for implementing an Activity that is used to help implement an AbstractAccountAuthenticator. @@ -34,7 +32,7 @@ import com.actionbarsherlock.app.SherlockFragmentActivity; * then error AccountManager.ERROR_CODE_CANCELED will be called on the response. */ -public class AccountAuthenticatorActivity extends SherlockFragmentActivity { +public class AccountAuthenticatorActivity extends AppCompatActivity { private AccountAuthenticatorResponse mAccountAuthenticatorResponse = null; private Bundle mResultBundle = null; diff --git a/src/com/owncloud/android/authentication/AuthenticatorActivity.java b/src/com/owncloud/android/authentication/AuthenticatorActivity.java index 713851ba..d5ba29fa 100644 --- a/src/com/owncloud/android/authentication/AuthenticatorActivity.java +++ b/src/com/owncloud/android/authentication/AuthenticatorActivity.java @@ -42,6 +42,7 @@ import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.preference.PreferenceManager; +import android.support.v4.app.DialogFragment; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; @@ -65,7 +66,6 @@ import android.widget.TextView; import android.widget.TextView.OnEditorActionListener; import android.widget.Toast; -import com.actionbarsherlock.app.SherlockDialogFragment; import com.owncloud.android.MainApp; import com.owncloud.android.R; import com.owncloud.android.authentication.SsoWebViewClient.SsoWebViewClientListener; @@ -189,8 +189,10 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity /// Identifier of operation in progress which result shouldn't be lost private long mWaitingForOpId = Long.MAX_VALUE; - private final String BASIC_TOKEN_TYPE = AccountTypeUtils.getAuthTokenTypePass(MainApp.getAccountType()); - private final String OAUTH_TOKEN_TYPE = AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType()); + private final String BASIC_TOKEN_TYPE = AccountTypeUtils.getAuthTokenTypePass( + MainApp.getAccountType()); + private final String OAUTH_TOKEN_TYPE = AccountTypeUtils.getAuthTokenTypeAccessToken( + MainApp.getAccountType()); private final String SAML_TOKEN_TYPE = AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()); @@ -204,7 +206,7 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity protected void onCreate(Bundle savedInstanceState) { //Log_OC.wtf(TAG, "onCreate init"); super.onCreate(savedInstanceState); - getWindow().requestFeature(Window.FEATURE_NO_TITLE); + //getWindow().requestFeature(Window.FEATURE_NO_TITLE); mIsFirstAuthAttempt = true; @@ -908,7 +910,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity dialog.show(getSupportFragmentManager(), WAIT_DIALOG_TAG); /// validate credentials accessing the root folder - OwnCloudCredentials credentials = OwnCloudCredentialsFactory.newBasicCredentials(username, password); + OwnCloudCredentials credentials = OwnCloudCredentialsFactory.newBasicCredentials(username, + password); accessRootFolder(credentials); } @@ -1016,7 +1019,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity } catch (AccountNotFoundException e) { Log_OC.e(TAG, "Account " + mAccount + " was removed!", e); - Toast.makeText(this, R.string.auth_account_does_not_exist, Toast.LENGTH_SHORT).show(); + Toast.makeText(this, R.string.auth_account_does_not_exist, + Toast.LENGTH_SHORT).show(); finish(); } } @@ -1324,7 +1328,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity Log_OC.d(TAG, "Got ACCESS TOKEN: " + mAuthToken); /// validate token accessing to root folder / getting session - OwnCloudCredentials credentials = OwnCloudCredentialsFactory.newBearerCredentials(mAuthToken); + OwnCloudCredentials credentials = OwnCloudCredentialsFactory.newBearerCredentials( + mAuthToken); accessRootFolder(credentials); } else { @@ -1361,7 +1366,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity } catch (AccountNotFoundException e) { Log_OC.e(TAG, "Account " + mAccount + " was removed!", e); - Toast.makeText(this, R.string.auth_account_does_not_exist, Toast.LENGTH_SHORT).show(); + Toast.makeText(this, R.string.auth_account_does_not_exist, + Toast.LENGTH_SHORT).show(); finish(); } } @@ -1716,8 +1722,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity mAuthToken = sessionCookie; getRemoteUserNameOperation(sessionCookie, true); Fragment fd = getSupportFragmentManager().findFragmentByTag(SAML_DIALOG_TAG); - if (fd != null && fd instanceof SherlockDialogFragment) { - Dialog d = ((SherlockDialogFragment)fd).getDialog(); + if (fd != null && fd instanceof DialogFragment) { + Dialog d = ((DialogFragment)fd).getDialog(); if (d != null && d.isShowing()) { d.dismiss(); } @@ -1819,8 +1825,8 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity private void dismissDialog(String dialogTag){ Fragment frag = getSupportFragmentManager().findFragmentByTag(dialogTag); - if (frag != null && frag instanceof SherlockDialogFragment) { - SherlockDialogFragment dialog = (SherlockDialogFragment) frag; + if (frag != null && frag instanceof DialogFragment) { + DialogFragment dialog = (DialogFragment) frag; dialog.dismiss(); } } diff --git a/src/com/owncloud/android/files/FileMenuFilter.java b/src/com/owncloud/android/files/FileMenuFilter.java index 4b8c55d5..d6c075d6 100644 --- a/src/com/owncloud/android/files/FileMenuFilter.java +++ b/src/com/owncloud/android/files/FileMenuFilter.java @@ -96,39 +96,6 @@ public class FileMenuFilter { } } - /** - * Filters out the file actions available in the passed {@link Menu} taken into account - * the state of the {@link OCFile} held by the filter. - * - * Second method needed thanks to ActionBarSherlock. - * - * TODO Get rid of it when ActionBarSherlock is replaced for newer Android Support Library. - * - * @param menu Options or context menu to filter. - */ - public void filter(com.actionbarsherlock.view.Menu menu) { - - List toShow = new ArrayList(); - List toHide = new ArrayList(); - - filter(toShow, toHide); - - com.actionbarsherlock.view.MenuItem item = null; - for (int i : toShow) { - item = menu.findItem(i); - if (item != null) { - item.setVisible(true); - item.setEnabled(true); - } - } - for (int i : toHide) { - item = menu.findItem(i); - if (item != null) { - item.setVisible(false); - item.setEnabled(false); - } - } - } /** * Performs the real filtering, to be applied in the {@link Menu} by the caller methods. diff --git a/src/com/owncloud/android/ui/activity/ConflictsResolveActivity.java b/src/com/owncloud/android/ui/activity/ConflictsResolveActivity.java index c3db9a47..fa3eea6f 100644 --- a/src/com/owncloud/android/ui/activity/ConflictsResolveActivity.java +++ b/src/com/owncloud/android/ui/activity/ConflictsResolveActivity.java @@ -22,7 +22,6 @@ package com.owncloud.android.ui.activity; -import com.actionbarsherlock.app.ActionBar; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.files.services.FileUploader; import com.owncloud.android.lib.common.utils.Log_OC; @@ -31,6 +30,7 @@ import com.owncloud.android.ui.dialog.ConflictsResolveDialog.Decision; import com.owncloud.android.ui.dialog.ConflictsResolveDialog.OnConflictDecisionMadeListener; import com.owncloud.android.utils.DisplayUtils; +import android.app.ActionBar; import android.content.Intent; import android.os.Bundle; @@ -45,7 +45,7 @@ public class ConflictsResolveActivity extends FileActivity implements OnConflict @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - ActionBar actionBar = getSupportActionBar(); + ActionBar actionBar = getActionBar(); actionBar.setIcon(DisplayUtils.getSeasonalIconId()); } diff --git a/src/com/owncloud/android/ui/activity/ErrorsWhileCopyingHandlerActivity.java b/src/com/owncloud/android/ui/activity/ErrorsWhileCopyingHandlerActivity.java index 9405ca7d..3162dd7f 100644 --- a/src/com/owncloud/android/ui/activity/ErrorsWhileCopyingHandlerActivity.java +++ b/src/com/owncloud/android/ui/activity/ErrorsWhileCopyingHandlerActivity.java @@ -30,6 +30,7 @@ import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.support.v4.app.DialogFragment; +import android.support.v7.app.AppCompatActivity; import android.text.method.ScrollingMovementMethod; import android.view.LayoutInflater; import android.view.View; @@ -41,7 +42,6 @@ import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; -import com.actionbarsherlock.app.SherlockFragmentActivity; import com.owncloud.android.R; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; @@ -53,21 +53,25 @@ import com.owncloud.android.utils.FileStorageUtils; /** - * Activity reporting errors occurred when local files uploaded to an ownCloud account with an app in - * version under 1.3.16 where being copied to the ownCloud local folder. + * Activity reporting errors occurred when local files uploaded to an ownCloud account with an app + * in version under 1.3.16 where being copied to the ownCloud local folder. * * Allows the user move the files to the ownCloud local folder. let them unlinked to the remote * files. * * Shown when the error notification summarizing the list of errors is clicked by the user. */ -public class ErrorsWhileCopyingHandlerActivity extends SherlockFragmentActivity implements OnClickListener { +public class ErrorsWhileCopyingHandlerActivity extends AppCompatActivity + implements OnClickListener { private static final String TAG = ErrorsWhileCopyingHandlerActivity.class.getSimpleName(); - public static final String EXTRA_ACCOUNT = ErrorsWhileCopyingHandlerActivity.class.getCanonicalName() + ".EXTRA_ACCOUNT"; - public static final String EXTRA_LOCAL_PATHS = ErrorsWhileCopyingHandlerActivity.class.getCanonicalName() + ".EXTRA_LOCAL_PATHS"; - public static final String EXTRA_REMOTE_PATHS = ErrorsWhileCopyingHandlerActivity.class.getCanonicalName() + ".EXTRA_REMOTE_PATHS"; + public static final String EXTRA_ACCOUNT = + ErrorsWhileCopyingHandlerActivity.class.getCanonicalName() + ".EXTRA_ACCOUNT"; + public static final String EXTRA_LOCAL_PATHS = + ErrorsWhileCopyingHandlerActivity.class.getCanonicalName() + ".EXTRA_LOCAL_PATHS"; + public static final String EXTRA_REMOTE_PATHS = + ErrorsWhileCopyingHandlerActivity.class.getCanonicalName() + ".EXTRA_REMOTE_PATHS"; private static final String WAIT_DIALOG_TAG = "WAIT_DIALOG"; @@ -104,7 +108,8 @@ public class ErrorsWhileCopyingHandlerActivity extends SherlockFragmentActivity /// customize text message TextView textView = (TextView) findViewById(R.id.message); String appName = getString(R.string.app_name); - String message = String.format(getString(R.string.sync_foreign_files_forgotten_explanation), appName, appName, appName, appName, mAccount.name); + String message = String.format(getString(R.string.sync_foreign_files_forgotten_explanation), + appName, appName, appName, appName, mAccount.name); textView.setText(message); textView.setMovementMethod(new ScrollingMovementMethod()); @@ -129,13 +134,14 @@ public class ErrorsWhileCopyingHandlerActivity extends SherlockFragmentActivity /** - * Customized adapter, showing the local files as main text in two-lines list item and the remote files - * as the secondary text. + * Customized adapter, showing the local files as main text in two-lines list item and the + * remote files as the secondary text. */ public class ErrorsWhileCopyingListAdapter extends ArrayAdapter { ErrorsWhileCopyingListAdapter() { - super(ErrorsWhileCopyingHandlerActivity.this, android.R.layout.two_line_list_item, android.R.id.text1, mLocalPaths); + super(ErrorsWhileCopyingHandlerActivity.this, android.R.layout.two_line_list_item, + android.R.id.text1, mLocalPaths); } @Override @@ -150,7 +156,8 @@ public class ErrorsWhileCopyingHandlerActivity extends SherlockFragmentActivity public View getView (int position, View convertView, ViewGroup parent) { View view = convertView; if (view == null) { - LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); + LayoutInflater vi = (LayoutInflater) getSystemService( + Context.LAYOUT_INFLATER_SERVICE); view = vi.inflate(android.R.layout.two_line_list_item, null); } if (view != null) { @@ -161,7 +168,8 @@ public class ErrorsWhileCopyingHandlerActivity extends SherlockFragmentActivity text1.setText(String.format(getString(R.string.foreign_files_local_text), localPath)); } } - if (mRemotePaths != null && mRemotePaths.size() > 0 && position >= 0 && position < mRemotePaths.size()) { + if (mRemotePaths != null && mRemotePaths.size() > 0 && position >= 0 && + position < mRemotePaths.size()) { TextView text2 = (TextView) view.findViewById(android.R.id.text2); String remotePath = mRemotePaths.get(position); if (text2 != null && remotePath != null) { @@ -261,12 +269,14 @@ public class ErrorsWhileCopyingHandlerActivity extends SherlockFragmentActivity if (result) { // nothing else to do in this activity - Toast t = Toast.makeText(ErrorsWhileCopyingHandlerActivity.this, getString(R.string.foreign_files_success), Toast.LENGTH_LONG); + Toast t = Toast.makeText(ErrorsWhileCopyingHandlerActivity.this, + getString(R.string.foreign_files_success), Toast.LENGTH_LONG); t.show(); finish(); } else { - Toast t = Toast.makeText(ErrorsWhileCopyingHandlerActivity.this, getString(R.string.foreign_files_fail), Toast.LENGTH_LONG); + Toast t = Toast.makeText(ErrorsWhileCopyingHandlerActivity.this, + getString(R.string.foreign_files_fail), Toast.LENGTH_LONG); t.show(); } } diff --git a/src/com/owncloud/android/ui/activity/FileActivity.java b/src/com/owncloud/android/ui/activity/FileActivity.java index fbb62edd..fb2d4107 100644 --- a/src/com/owncloud/android/ui/activity/FileActivity.java +++ b/src/com/owncloud/android/ui/activity/FileActivity.java @@ -37,9 +37,9 @@ import android.os.IBinder; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; +import android.support.v7.app.AppCompatActivity; import android.widget.Toast; -import com.actionbarsherlock.app.SherlockFragmentActivity; import com.owncloud.android.MainApp; import com.owncloud.android.R; import com.owncloud.android.authentication.AccountUtils; @@ -67,15 +67,18 @@ import com.owncloud.android.utils.ErrorMessageAdapter; /** - * Activity with common behaviour for activities handling {@link OCFile}s in ownCloud {@link Account}s . + * Activity with common behaviour for activities handling {@link OCFile}s in ownCloud + * {@link Account}s . */ -public class FileActivity extends SherlockFragmentActivity +public class FileActivity extends AppCompatActivity implements OnRemoteOperationListener, ComponentsGetter { public static final String EXTRA_FILE = "com.owncloud.android.ui.activity.FILE"; public static final String EXTRA_ACCOUNT = "com.owncloud.android.ui.activity.ACCOUNT"; - public static final String EXTRA_WAITING_TO_PREVIEW = "com.owncloud.android.ui.activity.WAITING_TO_PREVIEW"; - public static final String EXTRA_FROM_NOTIFICATION = "com.owncloud.android.ui.activity.FROM_NOTIFICATION"; + public static final String EXTRA_WAITING_TO_PREVIEW = + "com.owncloud.android.ui.activity.WAITING_TO_PREVIEW"; + public static final String EXTRA_FROM_NOTIFICATION = + "com.owncloud.android.ui.activity.FROM_NOTIFICATION"; public static final String TAG = FileActivity.class.getSimpleName(); @@ -87,13 +90,14 @@ public class FileActivity extends SherlockFragmentActivity protected static final long DELAY_TO_REQUEST_OPERATION_ON_ACTIVITY_RESULTS = 200; - /** OwnCloud {@link Account} where the main {@link OCFile} handled by the activity is located. */ + /** OwnCloud {@link Account} where the main {@link OCFile} handled by the activity is located.*/ private Account mAccount; /** Main {@link OCFile} handled by the activity.*/ private OCFile mFile; - /** Flag to signal that the activity will is finishing to enforce the creation of an ownCloud {@link Account} */ + /** Flag to signal that the activity will is finishing to enforce the creation of an ownCloud + * {@link Account} */ private boolean mRedirectingToSetupAccount = false; /** Flag to signal when the value of mAccount was set */ @@ -147,23 +151,28 @@ public class FileActivity extends SherlockFragmentActivity } else { account = getIntent().getParcelableExtra(FileActivity.EXTRA_ACCOUNT); mFile = getIntent().getParcelableExtra(FileActivity.EXTRA_FILE); - mFromNotification = getIntent().getBooleanExtra(FileActivity.EXTRA_FROM_NOTIFICATION, false); + mFromNotification = getIntent().getBooleanExtra(FileActivity.EXTRA_FROM_NOTIFICATION, + false); } - AccountUtils.updateAccountVersion(this); // best place, before any access to AccountManager or database + AccountUtils.updateAccountVersion(this); // best place, before any access to AccountManager + // or database setAccount(account, savedInstanceState != null); mOperationsServiceConnection = new OperationsServiceConnection(); - bindService(new Intent(this, OperationsService.class), mOperationsServiceConnection, Context.BIND_AUTO_CREATE); + bindService(new Intent(this, OperationsService.class), mOperationsServiceConnection, + Context.BIND_AUTO_CREATE); mDownloadServiceConnection = newTransferenceServiceConnection(); if (mDownloadServiceConnection != null) { - bindService(new Intent(this, FileDownloader.class), mDownloadServiceConnection, Context.BIND_AUTO_CREATE); + bindService(new Intent(this, FileDownloader.class), mDownloadServiceConnection, + Context.BIND_AUTO_CREATE); } mUploadServiceConnection = newTransferenceServiceConnection(); if (mUploadServiceConnection != null) { - bindService(new Intent(this, FileUploader.class), mUploadServiceConnection, Context.BIND_AUTO_CREATE); + bindService(new Intent(this, FileUploader.class), mUploadServiceConnection, + Context.BIND_AUTO_CREATE); } } @@ -255,7 +264,8 @@ public class FileActivity extends SherlockFragmentActivity protected void setAccount(Account account, boolean savedAccount) { Account oldAccount = mAccount; boolean validAccount = - (account != null && AccountUtils.setCurrentOwnCloudAccount(getApplicationContext(), account.name)); + (account != null && AccountUtils.setCurrentOwnCloudAccount(getApplicationContext(), + account.name)); if (validAccount) { mAccount = account; mAccountWasSet = true; @@ -342,9 +352,11 @@ public class FileActivity extends SherlockFragmentActivity /** - * Getter for the ownCloud {@link Account} where the main {@link OCFile} handled by the activity is located. + * Getter for the ownCloud {@link Account} where the main {@link OCFile} handled by the activity + * is located. * - * @return OwnCloud {@link Account} where the main {@link OCFile} handled by the activity is located. + * @return OwnCloud {@link Account} where the main {@link OCFile} handled by the activity + * is located. */ public Account getAccount() { return mAccount; @@ -464,7 +476,8 @@ public class FileActivity extends SherlockFragmentActivity */ @Override public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) { - Log_OC.d(TAG, "Received result of operation in FileActivity - common behaviour for all the FileActivities "); + Log_OC.d(TAG, "Received result of operation in FileActivity - common behaviour for all the " + + "FileActivities "); mFileOperationsHelper.setOpIdWaitingFor(Long.MAX_VALUE); @@ -542,15 +555,16 @@ public class FileActivity extends SherlockFragmentActivity } - private void onUnshareLinkOperationFinish(UnshareLinkOperation operation, RemoteOperationResult result) { + private void onUnshareLinkOperationFinish(UnshareLinkOperation operation, + RemoteOperationResult result) { dismissLoadingDialog(); if (result.isSuccess()){ updateFileFromDB(); } else { - Toast t = Toast.makeText(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()), - Toast.LENGTH_LONG); + Toast t = Toast.makeText(this, ErrorMessageAdapter.getErrorCauseMessage(result, + operation, getResources()), Toast.LENGTH_LONG); t.show(); } } @@ -559,8 +573,8 @@ public class FileActivity extends SherlockFragmentActivity SynchronizeFolderOperation operation, RemoteOperationResult result ) { if (!result.isSuccess() && result.getCode() != ResultCode.CANCELLED){ - Toast t = Toast.makeText(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()), - Toast.LENGTH_LONG); + Toast t = Toast.makeText(this, ErrorMessageAdapter.getErrorCauseMessage(result, + operation, getResources()), Toast.LENGTH_LONG); t.show(); } } @@ -602,7 +616,8 @@ public class FileActivity extends SherlockFragmentActivity mOperationsServiceBinder.addOperationListener(FileActivity.this, mHandler); long waitingForOpId = mFileOperationsHelper.getOpIdWaitingFor(); if (waitingForOpId <= Integer.MAX_VALUE) { - boolean wait = mOperationsServiceBinder.dispatchResultIfFinished((int)waitingForOpId, this); + boolean wait = mOperationsServiceBinder.dispatchResultIfFinished((int)waitingForOpId, + this); if (!wait ) { dismissLoadingDialog(); } diff --git a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java index 3061ff44..67173d7e 100644 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -50,18 +50,17 @@ import android.provider.OpenableColumns; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; +import android.support.v7.app.ActionBar; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; +import android.view.Window; import android.widget.ArrayAdapter; import android.widget.TextView; import android.widget.Toast; -import com.actionbarsherlock.app.ActionBar; -import com.actionbarsherlock.app.ActionBar.OnNavigationListener; -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuInflater; -import com.actionbarsherlock.view.MenuItem; -import com.actionbarsherlock.view.Window; import com.owncloud.android.BuildConfig; import com.owncloud.android.MainApp; import com.owncloud.android.R; @@ -113,8 +112,8 @@ import com.owncloud.android.utils.UriUtils; */ public class FileDisplayActivity extends HookActivity implements -FileFragment.ContainerActivity, OnNavigationListener, -OnSslUntrustedCertListener, OnEnforceableRefreshListener { + FileFragment.ContainerActivity, ActionBar.OnNavigationListener, + OnSslUntrustedCertListener, OnEnforceableRefreshListener { private ArrayAdapter mDirectories; @@ -159,7 +158,8 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { Log_OC.v(TAG, "onCreate() start"); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); - super.onCreate(savedInstanceState); // this calls onAccountChanged() when ownCloud Account is valid + super.onCreate(savedInstanceState); // this calls onAccountChanged() when ownCloud Account + // is valid /// grant that FileObserverService is watching favorite files if (savedInstanceState == null) { @@ -169,9 +169,11 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { /// Load of saved instance state if(savedInstanceState != null) { - mWaitingToPreview = (OCFile) savedInstanceState.getParcelable(FileDisplayActivity.KEY_WAITING_TO_PREVIEW); + mWaitingToPreview = (OCFile) savedInstanceState.getParcelable( + FileDisplayActivity.KEY_WAITING_TO_PREVIEW); mSyncInProgress = savedInstanceState.getBoolean(KEY_SYNC_IN_PROGRESS); - mWaitingToSend = (OCFile) savedInstanceState.getParcelable(FileDisplayActivity.KEY_WAITING_TO_SEND); + mWaitingToSend = (OCFile) savedInstanceState.getParcelable( + FileDisplayActivity.KEY_WAITING_TO_SEND); } else { mWaitingToPreview = null; @@ -191,9 +193,14 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { } // Action bar setup - mDirectories = new CustomArrayAdapter(this, R.layout.sherlock_spinner_dropdown_item); - getSupportActionBar().setHomeButtonEnabled(true); // mandatory since Android ICS, according to the official documentation - setSupportProgressBarIndeterminateVisibility(mSyncInProgress /*|| mRefreshSharesInProgress*/); // always AFTER setContentView(...) ; to work around bug in its implementation + mDirectories = new CustomArrayAdapter(this, + R.layout.support_simple_spinner_dropdown_item); + getSupportActionBar().setHomeButtonEnabled(true); // mandatory since Android ICS, + // according to the official + // documentation + setSupportProgressBarIndeterminateVisibility(mSyncInProgress + /*|| mRefreshSharesInProgress*/); + // always AFTER setContentView(...) ; to work around bug in its implementation setBackgroundText(); @@ -222,19 +229,22 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { protected void onAccountSet(boolean stateWasRecovered) { super.onAccountSet(stateWasRecovered); if (getAccount() != null) { - /// Check whether the 'main' OCFile handled by the Activity is contained in the current Account + /// Check whether the 'main' OCFile handled by the Activity is contained in the + // current Account OCFile file = getFile(); // get parent from path String parentPath = ""; if (file != null) { if (file.isDown() && file.getLastSyncDateForProperties() == 0) { - // upload in progress - right now, files are not inserted in the local cache until the upload is successful - // get parent from path - parentPath = file.getRemotePath().substring(0, file.getRemotePath().lastIndexOf(file.getFileName())); + // upload in progress - right now, files are not inserted in the local + // cache until the upload is successful get parent from path + parentPath = file.getRemotePath().substring(0, + file.getRemotePath().lastIndexOf(file.getFileName())); if (getStorageManager().getFileByPath(parentPath) == null) file = null; // not able to know the directory where the file is uploading } else { - file = getStorageManager().getFileByPath(file.getRemotePath()); // currentDir = null if not in the current Account + file = getStorageManager().getFileByPath(file.getRemotePath()); + // currentDir = null if not in the current Account } } if (file == null) { @@ -268,7 +278,8 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { mDirectories.add(fileIt.getFileName()); } // get parent from path - parentPath = fileIt.getRemotePath().substring(0, fileIt.getRemotePath().lastIndexOf(fileIt.getFileName())); + parentPath = fileIt.getRemotePath().substring(0, + fileIt.getRemotePath().lastIndexOf(fileIt.getFileName())); fileIt = getStorageManager().getFileByPath(parentPath); } mDirectories.add(OCFile.PATH_SEPARATOR); @@ -321,9 +332,12 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { if (file.isDown() && PreviewMediaFragment.canBePreviewed(file) && file.getLastSyncDateForProperties() > 0 // temporal fix ) { - int startPlaybackPosition = getIntent().getIntExtra(PreviewVideoActivity.EXTRA_START_POSITION, 0); - boolean autoplay = getIntent().getBooleanExtra(PreviewVideoActivity.EXTRA_AUTOPLAY, true); - secondFragment = new PreviewMediaFragment(file, getAccount(), startPlaybackPosition, autoplay); + int startPlaybackPosition = + getIntent().getIntExtra(PreviewVideoActivity.EXTRA_START_POSITION, 0); + boolean autoplay = + getIntent().getBooleanExtra(PreviewVideoActivity.EXTRA_AUTOPLAY, true); + secondFragment = new PreviewMediaFragment(file, getAccount(), + startPlaybackPosition, autoplay); } else { secondFragment = new FileDetailFragment(file, getAccount()); @@ -377,7 +391,8 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { private OCFileListFragment getListOfFilesFragment() { - Fragment listOfFiles = getSupportFragmentManager().findFragmentByTag(FileDisplayActivity.TAG_LIST_OF_FILES); + Fragment listOfFiles = getSupportFragmentManager().findFragmentByTag( + FileDisplayActivity.TAG_LIST_OF_FILES); if (listOfFiles != null) { return (OCFileListFragment)listOfFiles; } @@ -386,7 +401,8 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { } public FileFragment getSecondFragment() { - Fragment second = getSupportFragmentManager().findFragmentByTag(FileDisplayActivity.TAG_SECOND_FRAGMENT); + Fragment second = getSupportFragmentManager().findFragmentByTag( + FileDisplayActivity.TAG_SECOND_FRAGMENT); if (second != null) { return (FileFragment)second; } @@ -411,13 +427,16 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { } } - protected void refreshSecondFragment(String downloadEvent, String downloadedRemotePath, boolean success) { + protected void refreshSecondFragment(String downloadEvent, String downloadedRemotePath, + boolean success) { FileFragment secondFragment = getSecondFragment(); - boolean waitedPreview = (mWaitingToPreview != null && mWaitingToPreview.getRemotePath().equals(downloadedRemotePath)); + boolean waitedPreview = (mWaitingToPreview != null && + mWaitingToPreview.getRemotePath().equals(downloadedRemotePath)); if (secondFragment != null && secondFragment instanceof FileDetailFragment) { FileDetailFragment detailsFragment = (FileDetailFragment) secondFragment; OCFile fileInFragment = detailsFragment.getFile(); - if (fileInFragment != null && !downloadedRemotePath.equals(fileInFragment.getRemotePath())) { + if (fileInFragment != null && + !downloadedRemotePath.equals(fileInFragment.getRemotePath())) { // the user browsed to other file ; forget the automatic preview mWaitingToPreview = null; @@ -431,7 +450,9 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { boolean detailsFragmentChanged = false; if (waitedPreview) { if (success) { - mWaitingToPreview = getStorageManager().getFileById(mWaitingToPreview.getFileId()); // update the file from database, for the local storage path + mWaitingToPreview = getStorageManager().getFileById( + mWaitingToPreview.getFileId()); // update the file from database, + // for the local storage path if (PreviewMediaFragment.canBePreviewed(mWaitingToPreview)) { startMediaPreview(mWaitingToPreview, 0, true); detailsFragmentChanged = true; @@ -460,7 +481,7 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { @Override public boolean onCreateOptionsMenu(Menu menu) { - MenuInflater inflater = getSherlock().getMenuInflater(); + MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.main_menu, menu); return true; } @@ -544,16 +565,19 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { Log_OC.d(TAG, "Got to start sync"); if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.KITKAT) { Log_OC.d(TAG, "Canceling all syncs for " + MainApp.getAuthority()); - ContentResolver.cancelSync(null, MainApp.getAuthority()); // cancel the current synchronizations of any ownCloud account + ContentResolver.cancelSync(null, MainApp.getAuthority()); + // cancel the current synchronizations of any ownCloud account Bundle bundle = new Bundle(); bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); bundle.putBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, true); - Log_OC.d(TAG, "Requesting sync for " + getAccount().name + " at " + MainApp.getAuthority()); + Log_OC.d(TAG, "Requesting sync for " + getAccount().name + " at " + + MainApp.getAuthority()); ContentResolver.requestSync( getAccount(), MainApp.getAuthority(), bundle); } else { - Log_OC.d(TAG, "Requesting sync for " + getAccount().name + " at " + MainApp.getAuthority() + " with new API"); + Log_OC.d(TAG, "Requesting sync for " + getAccount().name + " at " + + MainApp.getAuthority() + " with new API"); SyncRequest.Builder builder = new SyncRequest.Builder(); builder.setSyncAdapter(getAccount(), MainApp.getAuthority()); builder.setExpedited(true); @@ -586,7 +610,8 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { // the next operation triggers a new call to this method, but it's necessary to // ensure that the name exposed in the action bar is the current directory when the // user selected it in the navigation list - if (getSupportActionBar().getNavigationMode() == ActionBar.NAVIGATION_MODE_LIST && itemPosition != 0) + if (getSupportActionBar().getNavigationMode() == ActionBar.NAVIGATION_MODE_LIST && + itemPosition != 0) getSupportActionBar().setSelectedNavigationItem(0); } return true; @@ -600,7 +625,8 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { - if (requestCode == ACTION_SELECT_CONTENT_FROM_APPS && (resultCode == RESULT_OK || resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)) { + if (requestCode == ACTION_SELECT_CONTENT_FROM_APPS && (resultCode == RESULT_OK || + resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)) { //getClipData is only supported on api level 16+, Jelly Bean if (data.getData() == null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN){ for( int i = 0; i < data.getClipData().getItemCount(); i++){ @@ -611,7 +637,8 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { }else { requestSimpleUpload(data, resultCode); } - } else if (requestCode == ACTION_SELECT_MULTIPLE_FILES && (resultCode == RESULT_OK || resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)) { + } else if (requestCode == ACTION_SELECT_MULTIPLE_FILES && (resultCode == RESULT_OK || + resultCode == UploadFilesActivity.RESULT_OK_AND_MOVE)) { requestMultipleUpload(data, resultCode); } else if (requestCode == ACTION_MOVE_FILES && resultCode == RESULT_OK){ @@ -685,13 +712,15 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { filePath = fileManagerString; } catch (Exception e) { - Log_OC.e(TAG, "Unexpected exception when trying to read the result of Intent.ACTION_GET_CONTENT", e); + Log_OC.e(TAG, "Unexpected exception when trying to read the result of " + + "Intent.ACTION_GET_CONTENT", e); } finally { if (filePath == null) { Log_OC.e(TAG, "Couldn't resolve path to file"); Toast t = Toast.makeText( - this, getString(R.string.filedisplay_unexpected_bad_get_content), Toast.LENGTH_LONG + this, getString(R.string.filedisplay_unexpected_bad_get_content), + Toast.LENGTH_LONG ); t.show(); return; @@ -707,7 +736,8 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { Cursor cursor = getContentResolver().query(Uri.parse(filePath), null, null, null, null); try { if (cursor != null && cursor.moveToFirst()) { - String displayName = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME)); + String displayName = cursor.getString(cursor.getColumnIndex( + OpenableColumns.DISPLAY_NAME)); Log_OC.v(TAG, "Display Name: " + displayName ); displayName.replace(File.separatorChar, '_'); @@ -769,12 +799,14 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { @Override protected void onSaveInstanceState(Bundle outState) { - // responsibility of restore is preferred in onCreate() before than in onRestoreInstanceState when there are Fragments involved + // responsibility of restore is preferred in onCreate() before than in + // onRestoreInstanceState when there are Fragments involved Log_OC.v(TAG, "onSaveInstanceState() start"); super.onSaveInstanceState(outState); outState.putParcelable(FileDisplayActivity.KEY_WAITING_TO_PREVIEW, mWaitingToPreview); outState.putBoolean(FileDisplayActivity.KEY_SYNC_IN_PROGRESS, mSyncInProgress); - //outState.putBoolean(FileDisplayActivity.KEY_REFRESH_SHARES_IN_PROGRESS, mRefreshSharesInProgress); + //outState.putBoolean(FileDisplayActivity.KEY_REFRESH_SHARES_IN_PROGRESS, + // mRefreshSharesInProgress); outState.putParcelable(FileDisplayActivity.KEY_WAITING_TO_SEND, mWaitingToSend); Log_OC.v(TAG, "onSaveInstanceState() end"); @@ -798,7 +830,8 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { syncIntentFilter.addAction(RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED); mSyncBroadcastReceiver = new SyncBroadcastReceiver(); registerReceiver(mSyncBroadcastReceiver, syncIntentFilter); - //LocalBroadcastManager.getInstance(this).registerReceiver(mSyncBroadcastReceiver, syncIntentFilter); + //LocalBroadcastManager.getInstance(this).registerReceiver(mSyncBroadcastReceiver, + // syncIntentFilter); // Listen for upload messages IntentFilter uploadIntentFilter = new IntentFilter(FileUploader.getUploadFinishMessage()); @@ -905,9 +938,13 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { String event = intent.getAction(); Log_OC.d(TAG, "Received broadcast " + event); String accountName = intent.getStringExtra(FileSyncAdapter.EXTRA_ACCOUNT_NAME); - String synchFolderRemotePath = intent.getStringExtra(FileSyncAdapter.EXTRA_FOLDER_PATH); - RemoteOperationResult synchResult = (RemoteOperationResult)intent.getSerializableExtra(FileSyncAdapter.EXTRA_RESULT); - boolean sameAccount = (getAccount() != null && accountName.equals(getAccount().name) && getStorageManager() != null); + String synchFolderRemotePath = + intent.getStringExtra(FileSyncAdapter.EXTRA_FOLDER_PATH); + RemoteOperationResult synchResult = + (RemoteOperationResult)intent.getSerializableExtra( + FileSyncAdapter.EXTRA_RESULT); + boolean sameAccount = (getAccount() != null && + accountName.equals(getAccount().name) && getStorageManager() != null); if (sameAccount) { @@ -915,13 +952,16 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { mSyncInProgress = true; } else { - OCFile currentFile = (getFile() == null) ? null : getStorageManager().getFileByPath(getFile().getRemotePath()); - OCFile currentDir = (getCurrentDir() == null) ? null : getStorageManager().getFileByPath(getCurrentDir().getRemotePath()); + OCFile currentFile = (getFile() == null) ? null : + getStorageManager().getFileByPath(getFile().getRemotePath()); + OCFile currentDir = (getCurrentDir() == null) ? null : + getStorageManager().getFileByPath(getCurrentDir().getRemotePath()); if (currentDir == null) { // current folder was removed from the server Toast.makeText( FileDisplayActivity.this, - String.format(getString(R.string.sync_current_folder_was_removed), mDirectories.getItem(0)), + String.format(getString(R.string.sync_current_folder_was_removed), + mDirectories.getItem(0)), Toast.LENGTH_LONG) .show(); browseToRoot(); @@ -933,7 +973,8 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { currentFile = currentDir; } - if (synchFolderRemotePath != null && currentDir.getRemotePath().equals(synchFolderRemotePath)) { + if (synchFolderRemotePath != null && + currentDir.getRemotePath().equals(synchFolderRemotePath)) { OCFileListFragment fileListFragment = getListOfFilesFragment(); if (fileListFragment != null) { fileListFragment.listDirectory(currentDir); @@ -942,7 +983,8 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { setFile(currentFile); } - mSyncInProgress = (!FileSyncAdapter.EVENT_FULL_SYNC_END.equals(event) && !RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED.equals(event)); + mSyncInProgress = (!FileSyncAdapter.EVENT_FULL_SYNC_END.equals(event) && + !RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED.equals(event)); if (RefreshFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED. equals(event) && @@ -985,14 +1027,16 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { } removeStickyBroadcast(intent); Log_OC.d(TAG, "Setting progress visibility to " + mSyncInProgress); - setSupportProgressBarIndeterminateVisibility(mSyncInProgress /*|| mRefreshSharesInProgress*/); + setSupportProgressBarIndeterminateVisibility(mSyncInProgress + /*|| mRefreshSharesInProgress*/); setBackgroundText(); } if (synchResult != null) { - if (synchResult.getCode().equals(RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED)) { + if (synchResult.getCode().equals( + RemoteOperationResult.ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED)) { mLastSslUntrustedServerResult = synchResult; } } @@ -1045,7 +1089,8 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { refreshListOfFilesFragment(); } - boolean uploadWasFine = intent.getBooleanExtra(FileUploader.EXTRA_UPLOAD_RESULT, false); + boolean uploadWasFine = intent.getBooleanExtra(FileUploader.EXTRA_UPLOAD_RESULT, + false); boolean renamedInUpload = getFile().getRemotePath(). equals(intent.getStringExtra(FileUploader.EXTRA_OLD_REMOTE_PATH)); boolean sameFile = getFile().getRemotePath().equals(uploadedRemotePath) || @@ -1104,11 +1149,13 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { public void onReceive(Context context, Intent intent) { try { boolean sameAccount = isSameAccount(context, intent); - String downloadedRemotePath = intent.getStringExtra(FileDownloader.EXTRA_REMOTE_PATH); + String downloadedRemotePath = + intent.getStringExtra(FileDownloader.EXTRA_REMOTE_PATH); boolean isDescendant = isDescendant(downloadedRemotePath); if (sameAccount && isDescendant) { - String linkedToRemotePath = intent.getStringExtra(FileDownloader.EXTRA_LINKED_TO_PATH); + String linkedToRemotePath = + intent.getStringExtra(FileDownloader.EXTRA_LINKED_TO_PATH); if (linkedToRemotePath == null || isAscendant(linkedToRemotePath)) { //Log_OC.v(TAG, "refresh #" + ++refreshCounter); refreshListOfFilesFragment(); @@ -1121,7 +1168,8 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { } if (mWaitingToSend != null) { - mWaitingToSend = getStorageManager().getFileByPath(mWaitingToSend.getRemotePath()); + mWaitingToSend = + getStorageManager().getFileByPath(mWaitingToSend.getRemotePath()); if (mWaitingToSend.isDown()) { sendDownloadedFile(); } @@ -1153,7 +1201,8 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { private boolean isSameAccount(Context context, Intent intent) { String accountName = intent.getStringExtra(FileDownloader.ACCOUNT_NAME); - return (accountName != null && getAccount() != null && accountName.equals(getAccount().name)); + return (accountName != null && getAccount() != null && + accountName.equals(getAccount().name)); } } @@ -1243,8 +1292,10 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { actionBarTitleView.setContentDescription(getString(R.string.default_display_name_for_root_folder)); } } - actionBar.setNavigationMode(!noRoot ? ActionBar.NAVIGATION_MODE_STANDARD : ActionBar.NAVIGATION_MODE_LIST); - actionBar.setListNavigationCallbacks(mDirectories, this); // assuming mDirectories is updated + actionBar.setNavigationMode(!noRoot ? ActionBar.NAVIGATION_MODE_STANDARD : + ActionBar.NAVIGATION_MODE_LIST); + actionBar.setListNavigationCallbacks(mDirectories, this); + // assuming mDirectories is updated } else { actionBar.setDisplayHomeAsUpEnabled(true); @@ -1275,19 +1326,23 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { mDownloaderBinder = (FileDownloaderBinder) service; if (mWaitingToPreview != null) if (getStorageManager() != null) { - mWaitingToPreview = getStorageManager().getFileById(mWaitingToPreview.getFileId()); // update the file + // update the file + mWaitingToPreview = + getStorageManager().getFileById(mWaitingToPreview.getFileId()); if (!mWaitingToPreview.isDown()) { requestForDownload(); } } - } else if (component.equals(new ComponentName(FileDisplayActivity.this, FileUploader.class))) { + } else if (component.equals(new ComponentName(FileDisplayActivity.this, + FileUploader.class))) { Log_OC.d(TAG, "Upload service connected"); mUploaderBinder = (FileUploaderBinder) service; } else { return; } - // a new chance to get the mDownloadBinder through getFileDownloadBinder() - THIS IS A MESS + // a new chance to get the mDownloadBinder through + // getFileDownloadBinder() - THIS IS A MESS OCFileListFragment listOfFiles = getListOfFilesFragment(); if (listOfFiles != null) { listOfFiles.listDirectory(); @@ -1302,10 +1357,12 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { @Override public void onServiceDisconnected(ComponentName component) { - if (component.equals(new ComponentName(FileDisplayActivity.this, FileDownloader.class))) { + if (component.equals(new ComponentName(FileDisplayActivity.this, + FileDownloader.class))) { Log_OC.d(TAG, "Download service disconnected"); mDownloaderBinder = null; - } else if (component.equals(new ComponentName(FileDisplayActivity.this, FileUploader.class))) { + } else if (component.equals(new ComponentName(FileDisplayActivity.this, + FileUploader.class))) { Log_OC.d(TAG, "Upload service disconnected"); mUploaderBinder = null; } @@ -1367,7 +1424,8 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { } - private void onCreateShareOperationFinish(CreateShareOperation operation, RemoteOperationResult result) { + private void onCreateShareOperationFinish(CreateShareOperation operation, + RemoteOperationResult result) { if (result.isSuccess()) { refreshShowDetails(); refreshListOfFilesFragment(); @@ -1375,7 +1433,8 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { } - private void onUnshareLinkOperationFinish(UnshareLinkOperation operation, RemoteOperationResult result) { + private void onUnshareLinkOperationFinish(UnshareLinkOperation operation, + RemoteOperationResult result) { if (result.isSuccess()) { refreshShowDetails(); refreshListOfFilesFragment(); @@ -1404,16 +1463,18 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { } /** - * Updates the view associated to the activity after the finish of an operation trying to remove a - * file. + * Updates the view associated to the activity after the finish of an operation trying to + * remove a file. * * @param operation Removal operation performed. * @param result Result of the removal. */ - private void onRemoveFileOperationFinish(RemoveFileOperation operation, RemoteOperationResult result) { + private void onRemoveFileOperationFinish(RemoveFileOperation operation, + RemoteOperationResult result) { dismissLoadingDialog(); - Toast msg = Toast.makeText(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()), + Toast msg = Toast.makeText(this, + ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()), Toast.LENGTH_LONG); msg.show(); @@ -1447,7 +1508,8 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { * @param operation Move operation performed. * @param result Result of the move operation. */ - private void onMoveFileOperationFinish(MoveFileOperation operation, RemoteOperationResult result) { + private void onMoveFileOperationFinish(MoveFileOperation operation, + RemoteOperationResult result) { if (result.isSuccess()) { dismissLoadingDialog(); refreshListOfFilesFragment(); @@ -1467,23 +1529,26 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { /** - * Updates the view associated to the activity after the finish of an operation trying to rename a - * file. + * Updates the view associated to the activity after the finish of an operation trying to rename + * a file. * * @param operation Renaming operation performed. * @param result Result of the renaming. */ - private void onRenameFileOperationFinish(RenameFileOperation operation, RemoteOperationResult result) { + private void onRenameFileOperationFinish(RenameFileOperation operation, + RemoteOperationResult result) { dismissLoadingDialog(); OCFile renamedFile = operation.getFile(); if (result.isSuccess()) { FileFragment details = getSecondFragment(); if (details != null) { - if (details instanceof FileDetailFragment && renamedFile.equals(details.getFile()) ) { + if (details instanceof FileDetailFragment && + renamedFile.equals(details.getFile()) ) { ((FileDetailFragment) details).updateFileDetails(renamedFile, getAccount()); showDetails(renamedFile); - } else if (details instanceof PreviewMediaFragment && renamedFile.equals(details.getFile())) { + } else if (details instanceof PreviewMediaFragment && + renamedFile.equals(details.getFile())) { ((PreviewMediaFragment) details).updateFile(renamedFile); if (PreviewMediaFragment.canBePreviewed(renamedFile)) { int position = ((PreviewMediaFragment)details).getPosition(); @@ -1494,12 +1559,13 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { } } - if (getStorageManager().getFileById(renamedFile.getParentId()).equals(getCurrentDir())) { + if (getStorageManager().getFileById(renamedFile.getParentId()).equals(getCurrentDir())){ refreshListOfFilesFragment(); } } else { - Toast msg = Toast.makeText(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()), + Toast msg = Toast.makeText(this, + ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()), Toast.LENGTH_LONG); msg.show(); @@ -1510,7 +1576,8 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { } } - private void onSynchronizeFileOperationFinish(SynchronizeFileOperation operation, RemoteOperationResult result) { + private void onSynchronizeFileOperationFinish(SynchronizeFileOperation operation, + RemoteOperationResult result) { dismissLoadingDialog(); OCFile syncedFile = operation.getLocalFile(); if (!result.isSuccess()) { @@ -1527,20 +1594,22 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { onTransferStateChanged(syncedFile, true, true); } else { - Toast msg = Toast.makeText(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()), - Toast.LENGTH_LONG); + Toast msg = Toast.makeText(this, ErrorMessageAdapter.getErrorCauseMessage(result, + operation, getResources()), Toast.LENGTH_LONG); msg.show(); } } } /** - * Updates the view associated to the activity after the finish of an operation trying create a new folder + * Updates the view associated to the activity after the finish of an operation trying create a + * new folder * * @param operation Creation operation performed. * @param result Result of the creation. */ - private void onCreateFolderOperationFinish(CreateFolderOperation operation, RemoteOperationResult result) { + private void onCreateFolderOperationFinish(CreateFolderOperation operation, + RemoteOperationResult result) { if (result.isSuccess()) { dismissLoadingDialog(); refreshListOfFilesFragment(); @@ -1566,7 +1635,8 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { public void onTransferStateChanged(OCFile file, boolean downloading, boolean uploading) { refreshListOfFilesFragment(); FileFragment details = getSecondFragment(); - if (details != null && details instanceof FileDetailFragment && file.equals(details.getFile()) ) { + if (details != null && details instanceof FileDetailFragment && + file.equals(details.getFile()) ) { if (downloading || uploading) { ((FileDetailFragment)details).updateFileDetails(file, getAccount()); } else { @@ -1614,14 +1684,14 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { // perform folder synchronization RemoteOperation synchFolderOp = new RefreshFolderOperation( folder, - currentSyncTime, - false, - getFileOperationsHelper().isSharedSupported(), - ignoreETag, - getStorageManager(), - getAccount(), - getApplicationContext() - ); + currentSyncTime, + false, + getFileOperationsHelper().isSharedSupported(), + ignoreETag, + getStorageManager(), + getAccount(), + getApplicationContext() + ); synchFolderOp.execute(getAccount(), MainApp.getAppContext(), this, null, null); setSupportProgressBarIndeterminateVisibility(true); @@ -1688,11 +1758,14 @@ OnSslUntrustedCertListener, OnEnforceableRefreshListener { * Stars the preview of an already down media {@link OCFile}. * * @param file Media {@link OCFile} to preview. - * @param startPlaybackPosition Media position where the playback will be started, in milliseconds. - * @param autoplay When 'true', the playback will start without user interactions. + * @param startPlaybackPosition Media position where the playback will be started, + * in milliseconds. + * @param autoplay When 'true', the playback will start without user + * interactions. */ public void startMediaPreview(OCFile file, int startPlaybackPosition, boolean autoplay) { - Fragment mediaFragment = new PreviewMediaFragment(file, getAccount(), startPlaybackPosition, autoplay); + Fragment mediaFragment = new PreviewMediaFragment(file, getAccount(), startPlaybackPosition, + autoplay); setSecondFragment(mediaFragment); updateFragmentsVisibility(true); updateNavigationElementsInActionBar(file); diff --git a/src/com/owncloud/android/ui/activity/FolderPickerActivity.java b/src/com/owncloud/android/ui/activity/FolderPickerActivity.java index 62299f27..5fd2bdf5 100644 --- a/src/com/owncloud/android/ui/activity/FolderPickerActivity.java +++ b/src/com/owncloud/android/ui/activity/FolderPickerActivity.java @@ -34,18 +34,17 @@ import android.os.Bundle; import android.os.Parcelable; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentTransaction; +import android.support.v7.app.ActionBar; import android.util.Log; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; +import android.view.Window; import android.widget.Button; import android.widget.Toast; -import com.actionbarsherlock.app.ActionBar; -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuInflater; -import com.actionbarsherlock.view.MenuItem; -import com.actionbarsherlock.view.Window; -import com.owncloud.android.MainApp; import com.owncloud.android.R; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.lib.common.OwnCloudAccount; @@ -262,7 +261,7 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C @Override public boolean onCreateOptionsMenu(Menu menu) { - MenuInflater inflater = getSherlock().getMenuInflater(); + MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.main_menu, menu); menu.findItem(R.id.action_upload).setVisible(false); menu.findItem(R.id.action_settings).setVisible(false); diff --git a/src/com/owncloud/android/ui/activity/GenericExplanationActivity.java b/src/com/owncloud/android/ui/activity/GenericExplanationActivity.java index 0d4ab01c..446b4657 100644 --- a/src/com/owncloud/android/ui/activity/GenericExplanationActivity.java +++ b/src/com/owncloud/android/ui/activity/GenericExplanationActivity.java @@ -25,6 +25,8 @@ import java.util.ArrayList; import android.content.Context; import android.content.Intent; import android.os.Bundle; +import android.support.v7.app.ActionBar; +import android.support.v7.app.AppCompatActivity; import android.text.method.ScrollingMovementMethod; import android.view.View; import android.view.ViewGroup; @@ -33,8 +35,6 @@ import android.widget.ListAdapter; import android.widget.ListView; import android.widget.TextView; -import com.actionbarsherlock.app.ActionBar; -import com.actionbarsherlock.app.SherlockFragmentActivity; import com.owncloud.android.R; import com.owncloud.android.utils.DisplayUtils; @@ -45,11 +45,14 @@ import com.owncloud.android.utils.DisplayUtils; * Added to show explanations for notifications when the user clicks on them, and there no place * better to show them. */ -public class GenericExplanationActivity extends SherlockFragmentActivity { +public class GenericExplanationActivity extends AppCompatActivity { - public static final String EXTRA_LIST = GenericExplanationActivity.class.getCanonicalName() + ".EXTRA_LIST"; - public static final String EXTRA_LIST_2 = GenericExplanationActivity.class.getCanonicalName() + ".EXTRA_LIST_2"; - public static final String MESSAGE = GenericExplanationActivity.class.getCanonicalName() + ".MESSAGE"; + public static final String EXTRA_LIST = GenericExplanationActivity.class.getCanonicalName() + + ".EXTRA_LIST"; + public static final String EXTRA_LIST_2 = GenericExplanationActivity.class.getCanonicalName() + + ".EXTRA_LIST_2"; + public static final String MESSAGE = GenericExplanationActivity.class.getCanonicalName() + + ".MESSAGE"; @Override @@ -71,7 +74,8 @@ public class GenericExplanationActivity extends SherlockFragmentActivity { ListView listView = (ListView) findViewById(R.id.list); if (list != null && list.size() > 0) { - //ListAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, list); + //ListAdapter adapter = new ArrayAdapter(this, + // android.R.layout.simple_list_item_1, list); ListAdapter adapter = new ExplanationListAdapterView(this, list, list2); listView.setAdapter(adapter); } else { @@ -87,7 +91,8 @@ public class GenericExplanationActivity extends SherlockFragmentActivity { ArrayList mList; ArrayList mList2; - ExplanationListAdapterView(Context context, ArrayList list, ArrayList list2) { + ExplanationListAdapterView(Context context, ArrayList list, + ArrayList list2) { super(context, android.R.layout.two_line_list_item, android.R.id.text1, list); mList = list; mList2 = list2; @@ -105,7 +110,8 @@ public class GenericExplanationActivity extends SherlockFragmentActivity { public View getView (int position, View convertView, ViewGroup parent) { View view = super.getView(position, convertView, parent); if (view != null) { - if (mList2 != null && mList2.size() > 0 && position >= 0 && position < mList2.size()) { + if (mList2 != null && mList2.size() > 0 && position >= 0 && + position < mList2.size()) { TextView text2 = (TextView) view.findViewById(android.R.id.text2); if (text2 != null) { text2.setText(mList2.get(position)); diff --git a/src/com/owncloud/android/ui/activity/LogHistoryActivity.java b/src/com/owncloud/android/ui/activity/LogHistoryActivity.java index 5640404b..b9657956 100644 --- a/src/com/owncloud/android/ui/activity/LogHistoryActivity.java +++ b/src/com/owncloud/android/ui/activity/LogHistoryActivity.java @@ -35,15 +35,15 @@ import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; +import android.support.v7.app.ActionBar; +import android.support.v7.app.AppCompatActivity; +import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; import android.widget.Toast; -import com.actionbarsherlock.app.ActionBar; -import com.actionbarsherlock.app.SherlockFragmentActivity; -import com.actionbarsherlock.view.MenuItem; import com.owncloud.android.R; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.ui.dialog.LoadingDialog; @@ -51,7 +51,7 @@ import com.owncloud.android.utils.DisplayUtils; import com.owncloud.android.utils.FileStorageUtils; -public class LogHistoryActivity extends SherlockFragmentActivity { +public class LogHistoryActivity extends AppCompatActivity { private static final String MAIL_ATTACHMENT_TYPE = "text/plain"; @@ -72,7 +72,7 @@ public class LogHistoryActivity extends SherlockFragmentActivity { setContentView(R.layout.log_send_file); setTitle(getText(R.string.actionbar_logger)); - ActionBar actionBar = getSherlock().getActionBar(); + ActionBar actionBar = getSupportActionBar(); actionBar.setIcon(DisplayUtils.getSeasonalIconId()); actionBar.setDisplayHomeAsUpEnabled(true); Button deleteHistoryButton = (Button) findViewById(R.id.deleteLogHistoryButton); @@ -117,14 +117,14 @@ public class LogHistoryActivity extends SherlockFragmentActivity { } @Override - public boolean onMenuItemSelected(int featureId, MenuItem item) { - super.onMenuItemSelected(featureId, item); + public boolean onOptionsItemSelected(MenuItem item) { + super.onOptionsItemSelected(item); switch (item.getItemId()) { - case android.R.id.home: - finish(); - break; - default: - return false; + case android.R.id.home: + finish(); + break; + default: + return false; } return true; } diff --git a/src/com/owncloud/android/ui/activity/PassCodeActivity.java b/src/com/owncloud/android/ui/activity/PassCodeActivity.java index 00cf1f06..de5ca8ad 100644 --- a/src/com/owncloud/android/ui/activity/PassCodeActivity.java +++ b/src/com/owncloud/android/ui/activity/PassCodeActivity.java @@ -27,6 +27,8 @@ import java.util.Arrays; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; +import android.support.v7.app.ActionBar; +import android.support.v7.app.AppCompatActivity; import android.text.Editable; import android.text.TextWatcher; import android.view.KeyEvent; @@ -37,13 +39,11 @@ import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; -import com.actionbarsherlock.app.ActionBar; -import com.actionbarsherlock.app.SherlockFragmentActivity; import com.owncloud.android.R; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.utils.DisplayUtils; -public class PassCodeActivity extends SherlockFragmentActivity { +public class PassCodeActivity extends AppCompatActivity { private static final String TAG = PassCodeActivity.class.getSimpleName(); diff --git a/src/com/owncloud/android/ui/activity/Preferences.java b/src/com/owncloud/android/ui/activity/Preferences.java index 33542085..23ab550a 100644 --- a/src/com/owncloud/android/ui/activity/Preferences.java +++ b/src/com/owncloud/android/ui/activity/Preferences.java @@ -40,20 +40,20 @@ import android.preference.CheckBoxPreference; import android.preference.Preference; import android.preference.Preference.OnPreferenceChangeListener; import android.preference.Preference.OnPreferenceClickListener; +import android.preference.PreferenceActivity; import android.preference.PreferenceCategory; import android.preference.PreferenceManager; +import android.support.v7.app.ActionBar; import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; +import android.view.Menu; +import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemLongClickListener; import android.widget.ListAdapter; import android.widget.ListView; -import com.actionbarsherlock.app.ActionBar; -import com.actionbarsherlock.app.SherlockPreferenceActivity; -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuItem; import com.owncloud.android.MainApp; import com.owncloud.android.R; import com.owncloud.android.authentication.AccountUtils; @@ -73,7 +73,7 @@ import com.owncloud.android.utils.DisplayUtils; /** * An Activity that allows the user to change the application's settings. */ -public class Preferences extends SherlockPreferenceActivity +public class Preferences extends PreferenceActivity implements AccountManagerCallback, ComponentsGetter { private static final String TAG = "OwnCloudPreferences"; @@ -110,10 +110,11 @@ public class Preferences extends SherlockPreferenceActivity mDbHandler = new DbHandler(getBaseContext()); addPreferencesFromResource(R.xml.preferences); - ActionBar actionBar = getSherlock().getActionBar(); - actionBar.setIcon(DisplayUtils.getSeasonalIconId()); - actionBar.setDisplayHomeAsUpEnabled(true); - actionBar.setTitle(R.string.actionbar_settings); + // TODO: Add Toolbar +// ActionBar actionBar = getSherlock().getActionBar(); +// actionBar.setIcon(DisplayUtils.getSeasonalIconId()); +// actionBar.setDisplayHomeAsUpEnabled(true); +// actionBar.setTitle(R.string.actionbar_settings); // For adding content description tag to a title field in the action bar int actionBarTitleId = getResources().getIdentifier("action_bar_title", "id", "android"); diff --git a/src/com/owncloud/android/ui/activity/UploadFilesActivity.java b/src/com/owncloud/android/ui/activity/UploadFilesActivity.java index fce4ddce..7a7f8e56 100644 --- a/src/com/owncloud/android/ui/activity/UploadFilesActivity.java +++ b/src/com/owncloud/android/ui/activity/UploadFilesActivity.java @@ -28,6 +28,8 @@ import android.os.AsyncTask; import android.os.Bundle; import android.os.Environment; import android.support.v4.app.DialogFragment; +import android.support.v7.app.ActionBar; +import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; @@ -35,9 +37,6 @@ import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.TextView; -import com.actionbarsherlock.app.ActionBar; -import com.actionbarsherlock.app.ActionBar.OnNavigationListener; -import com.actionbarsherlock.view.MenuItem; import com.owncloud.android.R; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.ui.dialog.ConfirmationDialogFragment; @@ -54,7 +53,8 @@ import com.owncloud.android.utils.FileStorageUtils; */ public class UploadFilesActivity extends FileActivity implements - LocalFileListFragment.ContainerActivity, OnNavigationListener, OnClickListener, ConfirmationDialogFragmentListener { + LocalFileListFragment.ContainerActivity, ActionBar.OnNavigationListener, + OnClickListener, ConfirmationDialogFragmentListener { private ArrayAdapter mDirectories; private File mCurrentDir = null; @@ -82,7 +82,8 @@ public class UploadFilesActivity extends FileActivity implements super.onCreate(savedInstanceState); if(savedInstanceState != null) { - mCurrentDir = new File(savedInstanceState.getString(UploadFilesActivity.KEY_DIRECTORY_PATH)); + mCurrentDir = new File(savedInstanceState.getString( + UploadFilesActivity.KEY_DIRECTORY_PATH)); } else { mCurrentDir = Environment.getExternalStorageDirectory(); } @@ -92,7 +93,8 @@ public class UploadFilesActivity extends FileActivity implements /// USER INTERFACE // Drop-down navigation - mDirectories = new CustomArrayAdapter(this, R.layout.sherlock_spinner_dropdown_item); + mDirectories = new CustomArrayAdapter(this, + R.layout.support_simple_spinner_dropdown_item); File currDir = mCurrentDir; while(currDir != null && currDir.getParentFile() != null) { mDirectories.add(currDir.getName()); @@ -102,7 +104,8 @@ public class UploadFilesActivity extends FileActivity implements // Inflate and set the layout view setContentView(R.layout.upload_files_layout); - mFileListFragment = (LocalFileListFragment) getSupportFragmentManager().findFragmentById(R.id.local_files_list); + mFileListFragment = (LocalFileListFragment) + getSupportFragmentManager().findFragmentById(R.id.local_files_list); // Set input controllers @@ -115,7 +118,8 @@ public class UploadFilesActivity extends FileActivity implements // Action bar setup ActionBar actionBar = getSupportActionBar(); actionBar.setIcon(DisplayUtils.getSeasonalIconId()); - actionBar.setHomeButtonEnabled(true); // mandatory since Android ICS, according to the official documentation + actionBar.setHomeButtonEnabled(true); // mandatory since Android ICS, according to the + // official documentation actionBar.setDisplayHomeAsUpEnabled(mCurrentDir != null && mCurrentDir.getName() != null); actionBar.setDisplayShowTitleEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); diff --git a/src/com/owncloud/android/ui/activity/Uploader.java b/src/com/owncloud/android/ui/activity/Uploader.java index 9e56a30b..f4bd273b 100644 --- a/src/com/owncloud/android/ui/activity/Uploader.java +++ b/src/com/owncloud/android/ui/activity/Uploader.java @@ -56,6 +56,8 @@ import android.provider.MediaStore.Video; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; +import android.support.v7.app.ActionBar; +import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; @@ -65,8 +67,6 @@ import android.widget.ListView; import android.widget.SimpleAdapter; import android.widget.Toast; -import com.actionbarsherlock.app.ActionBar; -import com.actionbarsherlock.view.MenuItem; import com.owncloud.android.MainApp; import com.owncloud.android.R; import com.owncloud.android.authentication.AccountAuthenticator; @@ -220,7 +220,8 @@ public class Uploader extends FileActivity builder.setPositiveButton(R.string.uploader_wrn_no_account_setup_btn_text, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.ECLAIR_MR1) { + if (android.os.Build.VERSION.SDK_INT > + android.os.Build.VERSION_CODES.ECLAIR_MR1) { // using string value since in API7 this // constatn is not defined // in API7 < this constatant is defined in diff --git a/src/com/owncloud/android/ui/dialog/ChangelogDialog.java b/src/com/owncloud/android/ui/dialog/ChangelogDialog.java index 24d7bc25..83c6053b 100644 --- a/src/com/owncloud/android/ui/dialog/ChangelogDialog.java +++ b/src/com/owncloud/android/ui/dialog/ChangelogDialog.java @@ -23,9 +23,9 @@ import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; +import android.support.v4.app.DialogFragment; import android.webkit.WebView; -import com.actionbarsherlock.app.SherlockDialogFragment; import com.owncloud.android.R; import com.owncloud.android.utils.DisplayUtils; @@ -33,15 +33,17 @@ import com.owncloud.android.utils.DisplayUtils; /** * Dialog to show the contents of res/raw/CHANGELOG.txt */ -public class ChangelogDialog extends SherlockDialogFragment { +public class ChangelogDialog extends DialogFragment { - private static final String ARG_CANCELABLE = ChangelogDialog.class.getCanonicalName() + ".ARG_CANCELABLE"; + private static final String ARG_CANCELABLE = ChangelogDialog.class.getCanonicalName() + + ".ARG_CANCELABLE"; /** * Public factory method to get dialog instances. * - * @param cancelable If 'true', the dialog can be cancelled by the user input (BACK button, touch outside...) + * @param cancelable If 'true', the dialog can be cancelled by the user input + * (BACK button, touch outside...) * @return New dialog instance, ready to show. */ public static ChangelogDialog newInstance(boolean cancelable) { @@ -60,7 +62,8 @@ public class ChangelogDialog extends SherlockDialogFragment { public Dialog onCreateDialog(Bundle savedInstanceState) { /// load the custom view to insert in the dialog, between title and WebView webview = new WebView(getActivity()); - webview.loadUrl("file:///android_res/raw/" + getResources().getResourceEntryName(R.raw.changelog) + ".html"); + webview.loadUrl("file:///android_res/raw/" + + getResources().getResourceEntryName(R.raw.changelog) + ".html"); /// build the dialog AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); @@ -84,7 +87,8 @@ public class ChangelogDialog extends SherlockDialogFragment { * {@inheritDoc} *-/ @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { /// load the custom layout View view = inflater.inflate(R.layout.fragment_changelog, container); mEditText = (EditText) view.findViewById(R.id.txt_your_name); diff --git a/src/com/owncloud/android/ui/dialog/ConfirmationDialogFragment.java b/src/com/owncloud/android/ui/dialog/ConfirmationDialogFragment.java index 48aabe5c..e2dbe850 100644 --- a/src/com/owncloud/android/ui/dialog/ConfirmationDialogFragment.java +++ b/src/com/owncloud/android/ui/dialog/ConfirmationDialogFragment.java @@ -24,12 +24,12 @@ import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; +import android.support.v4.app.DialogFragment; -import com.actionbarsherlock.app.SherlockDialogFragment; import com.owncloud.android.lib.common.utils.Log_OC; -public class ConfirmationDialogFragment extends SherlockDialogFragment { +public class ConfirmationDialogFragment extends DialogFragment { public final static String ARG_CONF_RESOURCE_ID = "resource_id"; public final static String ARG_CONF_ARGUMENTS = "string_array"; diff --git a/src/com/owncloud/android/ui/dialog/ConflictsResolveDialog.java b/src/com/owncloud/android/ui/dialog/ConflictsResolveDialog.java index 6cf229df..6ddc0e20 100644 --- a/src/com/owncloud/android/ui/dialog/ConflictsResolveDialog.java +++ b/src/com/owncloud/android/ui/dialog/ConflictsResolveDialog.java @@ -25,11 +25,11 @@ import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; +import android.support.v4.app.DialogFragment; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentTransaction; +import android.support.v7.app.AppCompatActivity; -import com.actionbarsherlock.app.SherlockDialogFragment; -import com.actionbarsherlock.app.SherlockFragmentActivity; import com.owncloud.android.R; import com.owncloud.android.utils.DisplayUtils; @@ -37,7 +37,7 @@ import com.owncloud.android.utils.DisplayUtils; /** * Dialog which will be displayed to user upon keep-in-sync file conflict. */ -public class ConflictsResolveDialog extends SherlockDialogFragment { +public class ConflictsResolveDialog extends DialogFragment { public static enum Decision { CANCEL, @@ -59,7 +59,7 @@ public class ConflictsResolveDialog extends SherlockDialogFragment { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { String remotepath = getArguments().getString("remotepath"); - return new AlertDialog.Builder(getSherlockActivity()) + return new AlertDialog.Builder(getActivity()) .setIcon(DisplayUtils.getSeasonalIconId()) .setTitle(R.string.conflict_title) .setMessage(String.format(getString(R.string.conflict_message), remotepath)) @@ -91,7 +91,7 @@ public class ConflictsResolveDialog extends SherlockDialogFragment { .create(); } - public void showDialog(SherlockFragmentActivity activity) { + public void showDialog(AppCompatActivity activity) { Fragment prev = activity.getSupportFragmentManager().findFragmentByTag("dialog"); FragmentTransaction ft = activity.getSupportFragmentManager().beginTransaction(); if (prev != null) { @@ -102,7 +102,7 @@ public class ConflictsResolveDialog extends SherlockDialogFragment { this.show(ft, "dialog"); } - public void dismissDialog(SherlockFragmentActivity activity) { + public void dismissDialog(AppCompatActivity activity) { Fragment prev = activity.getSupportFragmentManager().findFragmentByTag(getTag()); if (prev != null) { FragmentTransaction ft = activity.getSupportFragmentManager().beginTransaction(); diff --git a/src/com/owncloud/android/ui/dialog/CreateFolderDialogFragment.java b/src/com/owncloud/android/ui/dialog/CreateFolderDialogFragment.java index 170fe08a..73ae8bd8 100644 --- a/src/com/owncloud/android/ui/dialog/CreateFolderDialogFragment.java +++ b/src/com/owncloud/android/ui/dialog/CreateFolderDialogFragment.java @@ -20,7 +20,6 @@ package com.owncloud.android.ui.dialog; -import com.actionbarsherlock.app.SherlockDialogFragment; import com.owncloud.android.R; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.lib.resources.files.FileUtils; @@ -30,6 +29,7 @@ import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; +import android.support.v4.app.DialogFragment; import android.view.LayoutInflater; import android.view.View; import android.view.WindowManager.LayoutParams; @@ -42,8 +42,8 @@ import android.widget.Toast; * * Triggers the folder creation when name is confirmed. */ -public class CreateFolderDialogFragment -extends SherlockDialogFragment implements DialogInterface.OnClickListener { +public class CreateFolderDialogFragment + extends DialogFragment implements DialogInterface.OnClickListener { private static final String ARG_PARENT_FOLDER = "PARENT_FOLDER"; @@ -52,7 +52,7 @@ extends SherlockDialogFragment implements DialogInterface.OnClickListener { /** * Public factory method to create new CreateFolderDialogFragment instances. * - * @param file File to remove. + * @param parentFolder Folder to create * @return Dialog ready to show. */ public static CreateFolderDialogFragment newInstance(OCFile parentFolder) { @@ -72,7 +72,7 @@ extends SherlockDialogFragment implements DialogInterface.OnClickListener { mParentFolder = getArguments().getParcelable(ARG_PARENT_FOLDER); // Inflate the layout for the dialog - LayoutInflater inflater = getSherlockActivity().getLayoutInflater(); + LayoutInflater inflater = getActivity().getLayoutInflater(); View v = inflater.inflate(R.layout.edit_box_dialog, null); // Setup layout @@ -81,7 +81,7 @@ extends SherlockDialogFragment implements DialogInterface.OnClickListener { inputText.requestFocus(); // Build the dialog - AlertDialog.Builder builder = new AlertDialog.Builder(getSherlockActivity()); + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(v) .setPositiveButton(R.string.common_ok, this) .setNegativeButton(R.string.common_cancel, this) @@ -101,7 +101,7 @@ extends SherlockDialogFragment implements DialogInterface.OnClickListener { if (newFolderName.length() <= 0) { Toast.makeText( - getSherlockActivity(), + getActivity(), R.string.filename_empty, Toast.LENGTH_LONG).show(); return; @@ -109,7 +109,7 @@ extends SherlockDialogFragment implements DialogInterface.OnClickListener { if (!FileUtils.isValidName(newFolderName)) { Toast.makeText( - getSherlockActivity(), + getActivity(), R.string.filename_forbidden_characters, Toast.LENGTH_LONG).show(); return; @@ -117,7 +117,7 @@ extends SherlockDialogFragment implements DialogInterface.OnClickListener { String path = mParentFolder.getRemotePath(); path += newFolderName + OCFile.PATH_SEPARATOR; - ((ComponentsGetter)getSherlockActivity()). + ((ComponentsGetter)getActivity()). getFileOperationsHelper().createFolder(path, false); } } diff --git a/src/com/owncloud/android/ui/dialog/CredentialsDialogFragment.java b/src/com/owncloud/android/ui/dialog/CredentialsDialogFragment.java index 1b99c7b0..c12b9dd7 100644 --- a/src/com/owncloud/android/ui/dialog/CredentialsDialogFragment.java +++ b/src/com/owncloud/android/ui/dialog/CredentialsDialogFragment.java @@ -19,7 +19,6 @@ package com.owncloud.android.ui.dialog; -import com.actionbarsherlock.app.SherlockDialogFragment; import com.owncloud.android.R; import com.owncloud.android.authentication.AuthenticatorActivity; @@ -28,6 +27,7 @@ import android.app.Dialog; import android.app.AlertDialog.Builder; import android.content.DialogInterface; import android.os.Bundle; +import android.support.v4.app.DialogFragment; import android.text.InputType; import android.view.WindowManager.LayoutParams; import android.webkit.HttpAuthHandler; @@ -41,7 +41,7 @@ import android.widget.LinearLayout; * Dialog to input authentication credentials * */ -public class CredentialsDialogFragment extends SherlockDialogFragment +public class CredentialsDialogFragment extends DialogFragment implements DialogInterface.OnClickListener { private WebView mWebView = null; @@ -60,9 +60,11 @@ public class CredentialsDialogFragment extends SherlockDialogFragment * @param handler HttpAuthHandler * @return Dialog ready to show */ - public static CredentialsDialogFragment newInstanceForCredentials(WebView webView, HttpAuthHandler handler) { + public static CredentialsDialogFragment newInstanceForCredentials(WebView webView, + HttpAuthHandler handler) { if (handler == null) { - throw new IllegalArgumentException("Trying to create instance with parameter handler == null"); + throw new IllegalArgumentException("Trying to create instance with parameter handler" + + " == null"); } CredentialsDialogFragment frag = new CredentialsDialogFragment(); frag.mHandler = handler; @@ -75,16 +77,16 @@ public class CredentialsDialogFragment extends SherlockDialogFragment public Dialog onCreateDialog(Bundle savedInstanceState) { // Create field for username - mUsernameET = new EditText(getSherlockActivity()); - mUsernameET.setHint(getSherlockActivity().getText(R.string.auth_username)); + mUsernameET = new EditText(getActivity()); + mUsernameET.setHint(getActivity().getText(R.string.auth_username)); // Create field for password - mPasswordET = new EditText(getSherlockActivity()); - mPasswordET.setHint(getSherlockActivity().getText(R.string.auth_password)); + mPasswordET = new EditText(getActivity()); + mPasswordET.setHint(getActivity().getText(R.string.auth_password)); mPasswordET.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); // Prepare LinearLayout for dialog - LinearLayout ll = new LinearLayout(getSherlockActivity()); + LinearLayout ll = new LinearLayout(getActivity()); ll.setOrientation(LinearLayout.VERTICAL); ll.addView(mUsernameET); ll.addView(mPasswordET); @@ -94,8 +96,8 @@ public class CredentialsDialogFragment extends SherlockDialogFragment setRetainInstance(true); Builder authDialog = new AlertDialog - .Builder(getSherlockActivity()) - .setTitle(getSherlockActivity().getText(R.string.saml_authentication_required_text)) + .Builder(getActivity()) + .setTitle(getActivity().getText(R.string.saml_authentication_required_text)) .setView(ll) .setCancelable(false) .setPositiveButton(R.string.common_ok, this) diff --git a/src/com/owncloud/android/ui/dialog/IndeterminateProgressDialog.java b/src/com/owncloud/android/ui/dialog/IndeterminateProgressDialog.java index 32fa4c65..6f4b680d 100644 --- a/src/com/owncloud/android/ui/dialog/IndeterminateProgressDialog.java +++ b/src/com/owncloud/android/ui/dialog/IndeterminateProgressDialog.java @@ -24,13 +24,13 @@ import android.app.ProgressDialog; import android.content.DialogInterface; import android.content.DialogInterface.OnKeyListener; import android.os.Bundle; +import android.support.v4.app.DialogFragment; import android.view.KeyEvent; -import com.actionbarsherlock.app.SherlockDialogFragment; import com.owncloud.android.R; -public class IndeterminateProgressDialog extends SherlockDialogFragment { +public class IndeterminateProgressDialog extends DialogFragment { private static final String ARG_MESSAGE_ID = IndeterminateProgressDialog.class.getCanonicalName() + ".ARG_MESSAGE_ID"; private static final String ARG_CANCELABLE = IndeterminateProgressDialog.class.getCanonicalName() + ".ARG_CANCELABLE"; diff --git a/src/com/owncloud/android/ui/dialog/RemoveFileDialogFragment.java b/src/com/owncloud/android/ui/dialog/RemoveFileDialogFragment.java index c3b7ed1e..782ed04d 100644 --- a/src/com/owncloud/android/ui/dialog/RemoveFileDialogFragment.java +++ b/src/com/owncloud/android/ui/dialog/RemoveFileDialogFragment.java @@ -93,7 +93,7 @@ implements ConfirmationDialogFragmentListener { */ @Override public void onConfirmation(String callerTag) { - ComponentsGetter cg = (ComponentsGetter)getSherlockActivity(); + ComponentsGetter cg = (ComponentsGetter)getActivity(); FileDataStorageManager storageManager = cg.getStorageManager(); if (storageManager.getFileById(mTargetFile.getFileId()) != null) { cg.getFileOperationsHelper().removeFile(mTargetFile, false); @@ -105,7 +105,7 @@ implements ConfirmationDialogFragmentListener { */ @Override public void onNeutral(String callerTag) { - ComponentsGetter cg = (ComponentsGetter)getSherlockActivity(); + ComponentsGetter cg = (ComponentsGetter)getActivity(); cg.getFileOperationsHelper().removeFile(mTargetFile, true); FileDataStorageManager storageManager = cg.getStorageManager(); diff --git a/src/com/owncloud/android/ui/dialog/RenameFileDialogFragment.java b/src/com/owncloud/android/ui/dialog/RenameFileDialogFragment.java index 0e7850b5..40930608 100644 --- a/src/com/owncloud/android/ui/dialog/RenameFileDialogFragment.java +++ b/src/com/owncloud/android/ui/dialog/RenameFileDialogFragment.java @@ -29,6 +29,7 @@ import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; +import android.support.v4.app.DialogFragment; import android.view.LayoutInflater; import android.view.View; import android.view.WindowManager.LayoutParams; @@ -36,7 +37,6 @@ import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; -import com.actionbarsherlock.app.SherlockDialogFragment; import com.owncloud.android.R; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.lib.resources.files.FileUtils; @@ -49,7 +49,7 @@ import com.owncloud.android.ui.activity.ComponentsGetter; * Triggers the rename operation when name is confirmed. */ public class RenameFileDialogFragment -extends SherlockDialogFragment implements DialogInterface.OnClickListener { + extends DialogFragment implements DialogInterface.OnClickListener { private static final String ARG_TARGET_FILE = "TARGET_FILE"; @@ -75,7 +75,7 @@ extends SherlockDialogFragment implements DialogInterface.OnClickListener { mTargetFile = getArguments().getParcelable(ARG_TARGET_FILE); // Inflate the layout for the dialog - LayoutInflater inflater = getSherlockActivity().getLayoutInflater(); + LayoutInflater inflater = getActivity().getLayoutInflater(); View v = inflater.inflate(R.layout.edit_box_dialog, null); // Setup layout @@ -93,7 +93,7 @@ extends SherlockDialogFragment implements DialogInterface.OnClickListener { inputText.requestFocus(); // Build the dialog - AlertDialog.Builder builder = new AlertDialog.Builder(getSherlockActivity()); + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(v) .setPositiveButton(R.string.common_ok, this) .setNegativeButton(R.string.common_cancel, this) @@ -113,7 +113,7 @@ extends SherlockDialogFragment implements DialogInterface.OnClickListener { if (newFileName.length() <= 0) { Toast.makeText( - getSherlockActivity(), + getActivity(), R.string.filename_empty, Toast.LENGTH_LONG).show(); return; @@ -121,13 +121,14 @@ extends SherlockDialogFragment implements DialogInterface.OnClickListener { if (!FileUtils.isValidName(newFileName)) { Toast.makeText( - getSherlockActivity(), + getActivity(), R.string.filename_forbidden_characters, Toast.LENGTH_LONG).show(); return; } - ((ComponentsGetter)getSherlockActivity()).getFileOperationsHelper().renameFile(mTargetFile, newFileName); + ((ComponentsGetter)getActivity()).getFileOperationsHelper().renameFile(mTargetFile, + newFileName); } } } diff --git a/src/com/owncloud/android/ui/dialog/SamlWebViewDialog.java b/src/com/owncloud/android/ui/dialog/SamlWebViewDialog.java index 9c340200..ab6fb3fd 100644 --- a/src/com/owncloud/android/ui/dialog/SamlWebViewDialog.java +++ b/src/com/owncloud/android/ui/dialog/SamlWebViewDialog.java @@ -27,6 +27,7 @@ import android.app.Dialog; import android.content.DialogInterface; import android.os.Bundle; import android.os.Handler; +import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentTransaction; import android.support.v4.app.FragmentManager; import android.view.LayoutInflater; @@ -38,7 +39,6 @@ import android.webkit.WebSettings; import android.webkit.WebView; import android.widget.RelativeLayout; -import com.actionbarsherlock.app.SherlockDialogFragment; import com.owncloud.android.MainApp; import com.owncloud.android.R; import com.owncloud.android.authentication.SsoWebViewClient; @@ -49,7 +49,7 @@ import com.owncloud.android.lib.common.utils.Log_OC; /** * Dialog to show the WebView for SAML Authentication */ -public class SamlWebViewDialog extends SherlockDialogFragment { +public class SamlWebViewDialog extends DialogFragment { public final String SAML_DIALOG_TAG = "SamlWebViewDialog"; @@ -72,7 +72,8 @@ public class SamlWebViewDialog extends SherlockDialogFragment { * Public factory method to get dialog instances. * * @param url Url to open at WebView - * @param targetUrl mBaseUrl + AccountUtils.getWebdavPath(mDiscoveredVersion, mCurrentAuthTokenType) + * @param targetUrl mBaseUrl + AccountUtils.getWebdavPath(mDiscoveredVersion, m + * CurrentAuthTokenType) * @return New dialog instance, ready to show. */ public static SamlWebViewDialog newInstance(String url, String targetUrl) { @@ -114,7 +115,7 @@ public class SamlWebViewDialog extends SherlockDialogFragment { setRetainInstance(true); - CookieSyncManager.createInstance(getSherlockActivity().getApplicationContext()); + CookieSyncManager.createInstance(getActivity().getApplicationContext()); if (savedInstanceState == null) { mInitialUrl = getArguments().getString(ARG_INITIAL_URL); @@ -124,7 +125,7 @@ public class SamlWebViewDialog extends SherlockDialogFragment { mTargetUrl = savedInstanceState.getString(ARG_TARGET_URL); } - setStyle(SherlockDialogFragment.STYLE_NO_TITLE, R.style.Theme_ownCloud_Dialog); + setStyle(DialogFragment.STYLE_NO_TITLE, R.style.Theme_ownCloud_Dialog); } @SuppressWarnings("deprecation") @@ -140,7 +141,7 @@ public class SamlWebViewDialog extends SherlockDialogFragment { if (mSsoWebView == null) { // initialize the WebView - mSsoWebView = new SsoWebView(getSherlockActivity().getApplicationContext()); + mSsoWebView = new SsoWebView(getActivity().getApplicationContext()); mSsoWebView.setFocusable(true); mSsoWebView.setFocusableInTouchMode(true); mSsoWebView.setClickable(true); diff --git a/src/com/owncloud/android/ui/dialog/ShareLinkToDialog.java b/src/com/owncloud/android/ui/dialog/ShareLinkToDialog.java index fc88e5d1..29b591d2 100644 --- a/src/com/owncloud/android/ui/dialog/ShareLinkToDialog.java +++ b/src/com/owncloud/android/ui/dialog/ShareLinkToDialog.java @@ -35,6 +35,7 @@ import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.os.Bundle; +import android.support.v4.app.DialogFragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -42,7 +43,6 @@ import android.widget.ArrayAdapter; import android.widget.ImageView; import android.widget.TextView; -import com.actionbarsherlock.app.SherlockDialogFragment; import com.owncloud.android.R; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.lib.common.utils.Log_OC; @@ -54,18 +54,22 @@ import com.owncloud.android.ui.activity.FileActivity; * Dialog showing a list activities able to resolve a given Intent, * filtering out the activities matching give package names. */ -public class ShareLinkToDialog extends SherlockDialogFragment { +public class ShareLinkToDialog extends DialogFragment { private final static String TAG = ShareLinkToDialog.class.getSimpleName(); - private final static String ARG_INTENT = ShareLinkToDialog.class.getSimpleName() + ".ARG_INTENT"; - private final static String ARG_PACKAGES_TO_EXCLUDE = ShareLinkToDialog.class.getSimpleName() + ".ARG_PACKAGES_TO_EXCLUDE"; - private final static String ARG_FILE_TO_SHARE = ShareLinkToDialog.class.getSimpleName() + ".FILE_TO_SHARE"; + private final static String ARG_INTENT = ShareLinkToDialog.class.getSimpleName() + + ".ARG_INTENT"; + private final static String ARG_PACKAGES_TO_EXCLUDE = ShareLinkToDialog.class.getSimpleName() + + ".ARG_PACKAGES_TO_EXCLUDE"; + private final static String ARG_FILE_TO_SHARE = ShareLinkToDialog.class.getSimpleName() + + ".FILE_TO_SHARE"; private ActivityAdapter mAdapter; private OCFile mFile; private Intent mIntent; - public static ShareLinkToDialog newInstance(Intent intent, String[] packagesToExclude, OCFile fileToShare) { + public static ShareLinkToDialog newInstance(Intent intent, String[] packagesToExclude, + OCFile fileToShare) { ShareLinkToDialog f = new ShareLinkToDialog(); Bundle args = new Bundle(); args.putParcelable(ARG_INTENT, intent); @@ -84,16 +88,18 @@ public class ShareLinkToDialog extends SherlockDialogFragment { public Dialog onCreateDialog(Bundle savedInstanceState) { mIntent = getArguments().getParcelable(ARG_INTENT); String[] packagesToExclude = getArguments().getStringArray(ARG_PACKAGES_TO_EXCLUDE); - List packagesToExcludeList = Arrays.asList(packagesToExclude != null ? packagesToExclude : new String[0]); + List packagesToExcludeList = Arrays.asList(packagesToExclude != null ? + packagesToExclude : new String[0]); mFile = getArguments().getParcelable(ARG_FILE_TO_SHARE); - PackageManager pm= getSherlockActivity().getPackageManager(); - List activities = pm.queryIntentActivities(mIntent, PackageManager.MATCH_DEFAULT_ONLY); + PackageManager pm= getActivity().getPackageManager(); + List activities = pm.queryIntentActivities(mIntent, + PackageManager.MATCH_DEFAULT_ONLY); Iterator it = activities.iterator(); ResolveInfo resolveInfo; while (it.hasNext()) { resolveInfo = it.next(); - if (packagesToExcludeList.contains(resolveInfo.activityInfo.packageName.toLowerCase())) { + if (packagesToExcludeList.contains(resolveInfo.activityInfo.packageName.toLowerCase())){ it.remove(); } } @@ -102,7 +108,7 @@ public class ShareLinkToDialog extends SherlockDialogFragment { if (!sendAction) { // add activity for copy to clipboard - Intent copyToClipboardIntent = new Intent(getSherlockActivity(), CopyToClipboardActivity.class); + Intent copyToClipboardIntent = new Intent(getActivity(), CopyToClipboardActivity.class); List copyToClipboard = pm.queryIntentActivities(copyToClipboardIntent, 0); if (!copyToClipboard.isEmpty()) { activities.add(copyToClipboard.get(0)); @@ -110,7 +116,7 @@ public class ShareLinkToDialog extends SherlockDialogFragment { } Collections.sort(activities, new ResolveInfo.DisplayNameComparator(pm)); - mAdapter = new ActivityAdapter(getSherlockActivity(), pm, activities); + mAdapter = new ActivityAdapter(getActivity(), pm, activities); return createSelector(sendAction); @@ -125,7 +131,7 @@ public class ShareLinkToDialog extends SherlockDialogFragment { titleId = R.string.activity_chooser_title; } - return new AlertDialog.Builder(getSherlockActivity()) + return new AlertDialog.Builder(getActivity()) .setTitle(titleId) .setAdapter(mAdapter, new DialogInterface.OnClickListener() { @Override @@ -142,11 +148,11 @@ public class ShareLinkToDialog extends SherlockDialogFragment { dialog.dismiss(); // explicitly added for Android 2.x devices // Send the file - ((FileActivity)getSherlockActivity()).startActivity(mIntent); + ((FileActivity)getActivity()).startActivity(mIntent); } else { // Create a new share resource - ((ComponentsGetter)getSherlockActivity()).getFileOperationsHelper() + ((ComponentsGetter)getActivity()).getFileOperationsHelper() .shareFileWithLinkToApp(mFile, "", mIntent); } } @@ -173,7 +179,8 @@ public class ShareLinkToDialog extends SherlockDialogFragment { } private View newView(ViewGroup parent) { - return(((LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.activity_row, parent, false)); + return(((LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE)). + inflate(R.layout.activity_row, parent, false)); } private void bindView(int position, View row) { diff --git a/src/com/owncloud/android/ui/dialog/SharePasswordDialogFragment.java b/src/com/owncloud/android/ui/dialog/SharePasswordDialogFragment.java index d8f507b1..d2d29fef 100644 --- a/src/com/owncloud/android/ui/dialog/SharePasswordDialogFragment.java +++ b/src/com/owncloud/android/ui/dialog/SharePasswordDialogFragment.java @@ -23,6 +23,7 @@ import android.app.Dialog; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; +import android.support.v4.app.DialogFragment; import android.view.LayoutInflater; import android.view.View; import android.view.WindowManager; @@ -30,7 +31,6 @@ import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; -import com.actionbarsherlock.app.SherlockDialogFragment; import com.owncloud.android.R; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.ui.activity.FileActivity; @@ -41,7 +41,7 @@ import com.owncloud.android.ui.activity.FileActivity; * Triggers the share when the password is introduced. */ -public class SharePasswordDialogFragment extends SherlockDialogFragment +public class SharePasswordDialogFragment extends DialogFragment implements DialogInterface.OnClickListener { private static final String ARG_FILE = "FILE"; @@ -98,7 +98,7 @@ public class SharePasswordDialogFragment extends SherlockDialogFragment public void onClick(DialogInterface dialog, int which) { if (which == AlertDialog.BUTTON_POSITIVE) { // Enable the flag "Share again" - ((FileActivity) getSherlockActivity()).setTryShareAgain(true); + ((FileActivity) getActivity()).setTryShareAgain(true); String password = ((TextView)(getDialog().findViewById(R.id.share_password))) @@ -113,12 +113,12 @@ public class SharePasswordDialogFragment extends SherlockDialogFragment } // Share the file - ((FileActivity)getSherlockActivity()).getFileOperationsHelper() + ((FileActivity)getActivity()).getFileOperationsHelper() .shareFileWithLinkToApp(mFile, password, mSendIntent); } else { // Disable the flag "Share again" - ((FileActivity) getSherlockActivity()).setTryShareAgain(false); + ((FileActivity) getActivity()).setTryShareAgain(false); } } } diff --git a/src/com/owncloud/android/ui/dialog/SslUntrustedCertDialog.java b/src/com/owncloud/android/ui/dialog/SslUntrustedCertDialog.java index 66582608..12f595a6 100644 --- a/src/com/owncloud/android/ui/dialog/SslUntrustedCertDialog.java +++ b/src/com/owncloud/android/ui/dialog/SslUntrustedCertDialog.java @@ -28,6 +28,7 @@ import android.app.Activity; import android.app.Dialog; import android.net.http.SslError; import android.os.Bundle; +import android.support.v4.app.DialogFragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -36,7 +37,6 @@ import android.view.View.OnClickListener; import android.webkit.SslErrorHandler; import android.widget.Button; -import com.actionbarsherlock.app.SherlockDialogFragment; import com.owncloud.android.R; import com.owncloud.android.lib.common.network.CertificateCombinedException; import com.owncloud.android.lib.common.network.NetworkUtils; @@ -53,7 +53,7 @@ import com.owncloud.android.ui.adapter.X509CertificateViewAdapter; * Abstract implementation of common functionality for different dialogs that * get the information about the error and the certificate from different classes. */ -public class SslUntrustedCertDialog extends SherlockDialogFragment { +public class SslUntrustedCertDialog extends DialogFragment { private final static String TAG = SslUntrustedCertDialog.class.getSimpleName(); @@ -192,7 +192,7 @@ public class SslUntrustedCertDialog extends SherlockDialogFragment { if (mHandler != null) { mHandler.cancel(); } - ((OnSslUntrustedCertListener)getSherlockActivity()).onCancelCertificate(); + ((OnSslUntrustedCertListener)getActivity()).onCancelCertificate(); } } @@ -206,7 +206,7 @@ public class SslUntrustedCertDialog extends SherlockDialogFragment { mHandler.proceed(); } if (m509Certificate != null) { - Activity activity = getSherlockActivity(); + Activity activity = getActivity(); try { NetworkUtils.addCertToKnownServersStore(m509Certificate, activity); // TODO make this asynchronously, it can take some time ((OnSslUntrustedCertListener)activity).onSavedCertificate(); diff --git a/src/com/owncloud/android/ui/dialog/UploadSourceDialogFragment.java b/src/com/owncloud/android/ui/dialog/UploadSourceDialogFragment.java index 2f6eeadf..7eb861c9 100644 --- a/src/com/owncloud/android/ui/dialog/UploadSourceDialogFragment.java +++ b/src/com/owncloud/android/ui/dialog/UploadSourceDialogFragment.java @@ -26,8 +26,8 @@ import android.content.DialogInterface; import android.content.Intent; import android.os.Build; import android.os.Bundle; +import android.support.v4.app.DialogFragment; -import com.actionbarsherlock.app.SherlockDialogFragment; import com.owncloud.android.R; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.ui.activity.FileActivity; @@ -39,10 +39,11 @@ import com.owncloud.android.ui.activity.UploadFilesActivity; * * Assumes that its parent activity extends {@link FileActivity} */ -public class UploadSourceDialogFragment extends SherlockDialogFragment { +public class UploadSourceDialogFragment extends DialogFragment { private final static String TAG = UploadSourceDialogFragment.class.getSimpleName(); - private final static String ARG_ACCOUNT = UploadSourceDialogFragment.class.getSimpleName() + ".ARG_ACCOUNT"; + private final static String ARG_ACCOUNT = UploadSourceDialogFragment.class.getSimpleName() + + ".ARG_ACCOUNT"; public static final int ACTION_SELECT_CONTENT_FROM_APPS = 1; public static final int ACTION_SELECT_MULTIPLE_FILES = 2; @@ -68,19 +69,20 @@ public class UploadSourceDialogFragment extends SherlockDialogFragment { getString(R.string.actionbar_upload_from_apps) }; - AlertDialog.Builder builder = new AlertDialog.Builder(getSherlockActivity()); + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.actionbar_upload); builder.setItems(allTheItems, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { if (item == 0) { - Intent action = new Intent(getSherlockActivity(), UploadFilesActivity.class); + Intent action = new Intent(getActivity(), UploadFilesActivity.class); action.putExtra( UploadFilesActivity.EXTRA_ACCOUNT, - ((FileActivity)getSherlockActivity()).getAccount() + ((FileActivity)getActivity()).getAccount() ); - //startActivityForResult(action, ACTION_SELECT_MULTIPLE_FILES); // this flow seems broken; - // Actionbarsherlock, maybe? - getSherlockActivity().startActivityForResult(action, ACTION_SELECT_MULTIPLE_FILES); + //startActivityForResult(action, ACTION_SELECT_MULTIPLE_FILES); + // this flow seems broken; + // Actionbarsherlock, maybe? + getActivity().startActivityForResult(action, ACTION_SELECT_MULTIPLE_FILES); } else if (item == 1) { Intent action = new Intent(Intent.ACTION_GET_CONTENT); @@ -91,7 +93,7 @@ public class UploadSourceDialogFragment extends SherlockDialogFragment { } //startActivityForResult( // this flow seems broken; // Actionbarsherlock, maybe? - getSherlockActivity().startActivityForResult( + getActivity().startActivityForResult( Intent.createChooser(action, getString(R.string.upload_chooser_title)), ACTION_SELECT_CONTENT_FROM_APPS ); diff --git a/src/com/owncloud/android/ui/fragment/AuthenticatorAccountDetailsFragment.java b/src/com/owncloud/android/ui/fragment/AuthenticatorAccountDetailsFragment.java index 1552da1e..91c86fb1 100644 --- a/src/com/owncloud/android/ui/fragment/AuthenticatorAccountDetailsFragment.java +++ b/src/com/owncloud/android/ui/fragment/AuthenticatorAccountDetailsFragment.java @@ -20,8 +20,8 @@ package com.owncloud.android.ui.fragment; -import com.actionbarsherlock.app.SherlockFragment; +import android.support.v4.app.Fragment; -public class AuthenticatorAccountDetailsFragment extends SherlockFragment { +public class AuthenticatorAccountDetailsFragment extends Fragment { } diff --git a/src/com/owncloud/android/ui/fragment/AuthenticatorGetStartedFragment.java b/src/com/owncloud/android/ui/fragment/AuthenticatorGetStartedFragment.java index 5a8da70d..dc673bf6 100644 --- a/src/com/owncloud/android/ui/fragment/AuthenticatorGetStartedFragment.java +++ b/src/com/owncloud/android/ui/fragment/AuthenticatorGetStartedFragment.java @@ -20,8 +20,8 @@ package com.owncloud.android.ui.fragment; -import com.actionbarsherlock.app.SherlockFragment; +import android.support.v4.app.Fragment; -public class AuthenticatorGetStartedFragment extends SherlockFragment { +public class AuthenticatorGetStartedFragment extends Fragment { } diff --git a/src/com/owncloud/android/ui/fragment/ExtendedListFragment.java b/src/com/owncloud/android/ui/fragment/ExtendedListFragment.java index fb58be3a..2432380f 100644 --- a/src/com/owncloud/android/ui/fragment/ExtendedListFragment.java +++ b/src/com/owncloud/android/ui/fragment/ExtendedListFragment.java @@ -24,6 +24,7 @@ import java.util.ArrayList; import android.os.Build; import android.os.Bundle; +import android.support.v4.app.Fragment; import android.support.v4.widget.SwipeRefreshLayout; import android.view.LayoutInflater; import android.view.View; @@ -36,7 +37,6 @@ import android.widget.ListAdapter; import android.widget.ListView; import android.widget.TextView; -import com.actionbarsherlock.app.SherlockFragment; import com.owncloud.android.R; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.ui.ExtendedListView; @@ -48,8 +48,8 @@ import third_parties.in.srain.cube.GridViewWithHeaderAndFooter; /** * TODO extending SherlockListFragment instead of SherlockFragment */ -public class ExtendedListFragment extends SherlockFragment -implements OnItemClickListener, OnEnforceableRefreshListener { +public class ExtendedListFragment extends Fragment + implements OnItemClickListener, OnEnforceableRefreshListener { private static final String TAG = ExtendedListFragment.class.getSimpleName(); @@ -130,7 +130,8 @@ implements OnItemClickListener, OnEnforceableRefreshListener { @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { Log_OC.d(TAG, "onCreateView"); View v = inflater.inflate(R.layout.list_fragment, null); diff --git a/src/com/owncloud/android/ui/fragment/FileDetailFragment.java b/src/com/owncloud/android/ui/fragment/FileDetailFragment.java index 6a19957b..bff9cea4 100644 --- a/src/com/owncloud/android/ui/fragment/FileDetailFragment.java +++ b/src/com/owncloud/android/ui/fragment/FileDetailFragment.java @@ -27,6 +27,9 @@ import android.accounts.Account; import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; @@ -35,9 +38,6 @@ import android.widget.ImageView; import android.widget.ProgressBar; import android.widget.TextView; -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuInflater; -import com.actionbarsherlock.view.MenuItem; import com.owncloud.android.R; import com.owncloud.android.datamodel.FileDataStorageManager; import com.owncloud.android.datamodel.OCFile; @@ -181,7 +181,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener getFile(), mContainerActivity.getStorageManager().getAccount(), mContainerActivity, - getSherlockActivity() + getActivity() ); mf.filter(menu); } @@ -360,7 +360,8 @@ public class FileDetailFragment extends FileFragment implements OnClickListener setButtonsForDown(); } else { - // TODO load default preview image; when the local file is removed, the preview remains there + // TODO load default preview image; when the local file is removed, the preview + // remains there setButtonsForRemote(); } } @@ -500,7 +501,8 @@ public class FileDetailFragment extends FileFragment implements OnClickListener */ private boolean ocVersionSupportsTimeCreated(){ /*if(mAccount != null){ - AccountManager accManager = (AccountManager) getActivity().getSystemService(Context.ACCOUNT_SERVICE); + AccountManager accManager = (AccountManager) getActivity() + .getSystemService(Context.ACCOUNT_SERVICE); OwnCloudVersion ocVersion = new OwnCloudVersion(accManager .getUserData(mAccount, AccountAuthenticator.KEY_OC_VERSION)); if(ocVersion.compareTo(new OwnCloudVersion(0x030000)) < 0) { @@ -514,10 +516,12 @@ public class FileDetailFragment extends FileFragment implements OnClickListener public void listenForTransferProgress() { if (mProgressListener != null) { if (mContainerActivity.getFileDownloaderBinder() != null) { - mContainerActivity.getFileDownloaderBinder().addDatatransferProgressListener(mProgressListener, mAccount, getFile()); + mContainerActivity.getFileDownloaderBinder(). + addDatatransferProgressListener(mProgressListener, mAccount, getFile()); } if (mContainerActivity.getFileUploaderBinder() != null) { - mContainerActivity.getFileUploaderBinder().addDatatransferProgressListener(mProgressListener, mAccount, getFile()); + mContainerActivity.getFileUploaderBinder(). + addDatatransferProgressListener(mProgressListener, mAccount, getFile()); } } } @@ -526,10 +530,12 @@ public class FileDetailFragment extends FileFragment implements OnClickListener public void leaveTransferProgress() { if (mProgressListener != null) { if (mContainerActivity.getFileDownloaderBinder() != null) { - mContainerActivity.getFileDownloaderBinder().removeDatatransferProgressListener(mProgressListener, mAccount, getFile()); + mContainerActivity.getFileDownloaderBinder(). + removeDatatransferProgressListener(mProgressListener, mAccount, getFile()); } if (mContainerActivity.getFileUploaderBinder() != null) { - mContainerActivity.getFileUploaderBinder().removeDatatransferProgressListener(mProgressListener, mAccount, getFile()); + mContainerActivity.getFileUploaderBinder(). + removeDatatransferProgressListener(mProgressListener, mAccount, getFile()); } } } @@ -537,7 +543,8 @@ public class FileDetailFragment extends FileFragment implements OnClickListener /** - * Helper class responsible for updating the progress bar shown for file uploading or downloading + * Helper class responsible for updating the progress bar shown for file uploading or + * downloading */ private class ProgressListener implements OnDatatransferProgressListener { int mLastPercent = 0; @@ -548,7 +555,8 @@ public class FileDetailFragment extends FileFragment implements OnClickListener } @Override - public void onTransferProgress(long progressRate, long totalTransferredSoFar, long totalToTransfer, String filename) { + public void onTransferProgress(long progressRate, long totalTransferredSoFar, + long totalToTransfer, String filename) { int percent = (int)(100.0*((double)totalTransferredSoFar)/((double)totalToTransfer)); if (percent != mLastPercent) { ProgressBar pb = mProgressBar.get(); diff --git a/src/com/owncloud/android/ui/fragment/FileFragment.java b/src/com/owncloud/android/ui/fragment/FileFragment.java index 87dca259..fd5aeefa 100644 --- a/src/com/owncloud/android/ui/fragment/FileFragment.java +++ b/src/com/owncloud/android/ui/fragment/FileFragment.java @@ -24,7 +24,6 @@ import android.accounts.Account; import android.app.Activity; import android.support.v4.app.Fragment; -import com.actionbarsherlock.app.SherlockFragment; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder; import com.owncloud.android.files.services.FileUploader.FileUploaderBinder; @@ -34,7 +33,7 @@ import com.owncloud.android.ui.activity.ComponentsGetter; /** * Common methods for {@link Fragment}s containing {@link OCFile}s */ -public class FileFragment extends SherlockFragment { +public class FileFragment extends Fragment { private OCFile mFile; @@ -44,7 +43,8 @@ public class FileFragment extends SherlockFragment { /** * Creates an empty fragment. * - * It's necessary to keep a public constructor without parameters; the system uses it when tries to reinstantiate a fragment automatically. + * It's necessary to keep a public constructor without parameters; the system uses it when + * tries to reinstantiate a fragment automatically. */ public FileFragment() { mFile = null; @@ -84,7 +84,8 @@ public class FileFragment extends SherlockFragment { mContainerActivity = (ContainerActivity) activity; } catch (ClassCastException e) { - throw new ClassCastException(activity.toString() + " must implement " + ContainerActivity.class.getSimpleName()); + throw new ClassCastException(activity.toString() + " must implement " + + ContainerActivity.class.getSimpleName()); } } @@ -113,11 +114,13 @@ public class FileFragment extends SherlockFragment { public void showDetails(OCFile file); - ///// TO UNIFY IN A SINGLE CALLBACK METHOD - EVENT NOTIFICATIONs -> something happened inside the fragment, MAYBE activity is interested --> unify in notification method + ///// TO UNIFY IN A SINGLE CALLBACK METHOD - EVENT NOTIFICATIONs -> something happened + // inside the fragment, MAYBE activity is interested --> unify in notification method /** - * Callback method invoked when a the user browsed into a different folder through the list of files + * Callback method invoked when a the user browsed into a different folder through the + * list of files * - * @param file + * @param folder */ public void onBrowsedDownTo(OCFile folder); @@ -126,11 +129,13 @@ public class FileFragment extends SherlockFragment { * * This happens when a download or upload is started or ended for a file. * - * This method is necessary by now to update the user interface of the double-pane layout in tablets - * because methods {@link FileDownloaderBinder#isDownloading(Account, OCFile)} and {@link FileUploaderBinder#isUploading(Account, OCFile)} + * This method is necessary by now to update the user interface of the double-pane layout + * in tablets because methods {@link FileDownloaderBinder#isDownloading(Account, OCFile)} + * and {@link FileUploaderBinder#isUploading(Account, OCFile)} * won't provide the needed response before the method where this is called finishes. * - * TODO Remove this when the transfer state of a file is kept in the database (other thing TODO) + * TODO Remove this when the transfer state of a file is kept in the database + * (other thing TODO) * * @param file OCFile which state changed. * @param downloading Flag signaling if the file is now downloading. diff --git a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java index 60ac78d9..ed97de0b 100644 --- a/src/com/owncloud/android/ui/fragment/OCFileListFragment.java +++ b/src/com/owncloud/android/ui/fragment/OCFileListFragment.java @@ -132,7 +132,7 @@ public class OCFileListFragment extends ExtendedListFragment { mJustFolders = (args == null) ? false : args.getBoolean(ARG_JUST_FOLDERS, false); mAdapter = new FileListListAdapter( mJustFolders, - getSherlockActivity(), + getActivity(), mContainerActivity ); setListAdapter(mAdapter); @@ -244,7 +244,7 @@ public class OCFileListFragment extends ExtendedListFragment { boolean allowContextualActions = (args == null) ? true : args.getBoolean(ARG_ALLOW_CONTEXTUAL_ACTIONS, true); if (allowContextualActions) { - MenuInflater inflater = getSherlockActivity().getMenuInflater(); + MenuInflater inflater = getActivity().getMenuInflater(); inflater.inflate(R.menu.file_actions_menu, menu); AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo; OCFile targetFile = (OCFile) mAdapter.getItem(info.position); @@ -254,14 +254,14 @@ public class OCFileListFragment extends ExtendedListFragment { targetFile, mContainerActivity.getStorageManager().getAccount(), mContainerActivity, - getSherlockActivity() + getActivity() ); mf.filter(menu); } /// TODO break this direct dependency on FileDisplayActivity... if possible MenuItem item = menu.findItem(R.id.action_open_file_with); - FileFragment frag = ((FileDisplayActivity)getSherlockActivity()).getSecondFragment(); + FileFragment frag = ((FileDisplayActivity)getActivity()).getSecondFragment(); if (frag != null && frag instanceof FileDetailFragment && frag.getFile().getFileId() == targetFile.getFileId()) { item = menu.findItem(R.id.action_see_details); diff --git a/src/com/owncloud/android/ui/preview/PreviewImageActivity.java b/src/com/owncloud/android/ui/preview/PreviewImageActivity.java index f3b2ddc7..216dff5b 100644 --- a/src/com/owncloud/android/ui/preview/PreviewImageActivity.java +++ b/src/com/owncloud/android/ui/preview/PreviewImageActivity.java @@ -32,11 +32,11 @@ import android.os.Handler; import android.os.IBinder; import android.os.Message; import android.support.v4.view.ViewPager; +import android.support.v7.app.ActionBar; +import android.view.MenuItem; import android.view.View; +import android.view.Window; -import com.actionbarsherlock.app.ActionBar; -import com.actionbarsherlock.view.MenuItem; -import com.actionbarsherlock.view.Window; import com.ortiz.touch.ExtendedViewPager; import com.owncloud.android.R; import com.owncloud.android.authentication.AccountUtils; @@ -133,21 +133,25 @@ ViewPager.OnPageChangeListener, OnRemoteOperationListener { private void initViewPager() { // get parent from path - String parentPath = getFile().getRemotePath().substring(0, getFile().getRemotePath().lastIndexOf(getFile().getFileName())); + String parentPath = getFile().getRemotePath().substring(0, + getFile().getRemotePath().lastIndexOf(getFile().getFileName())); OCFile parentFolder = getStorageManager().getFileByPath(parentPath); if (parentFolder == null) { // should not be necessary parentFolder = getStorageManager().getFileByPath(OCFile.ROOT_PATH); } - mPreviewImagePagerAdapter = new PreviewImagePagerAdapter(getSupportFragmentManager(), parentFolder, getAccount(), getStorageManager()); + mPreviewImagePagerAdapter = new PreviewImagePagerAdapter(getSupportFragmentManager(), + parentFolder, getAccount(), getStorageManager()); mViewPager = (ExtendedViewPager) findViewById(R.id.fragmentPager); - int position = mHasSavedPosition ? mSavedPosition : mPreviewImagePagerAdapter.getFilePosition(getFile()); + int position = mHasSavedPosition ? mSavedPosition : + mPreviewImagePagerAdapter.getFilePosition(getFile()); position = (position >= 0) ? position : 0; mViewPager.setAdapter(mPreviewImagePagerAdapter); mViewPager.setOnPageChangeListener(this); mViewPager.setCurrentItem(position); if (position == 0 && !getFile().isDown()) { - // this is necessary because mViewPager.setCurrentItem(0) just after setting the adapter does not result in a call to #onPageSelected(0) + // this is necessary because mViewPager.setCurrentItem(0) just after setting the + // adapter does not result in a call to #onPageSelected(0) mRequestWaitingForBinder = true; } } @@ -220,7 +224,8 @@ ViewPager.OnPageChangeListener, OnRemoteOperationListener { } - private void onUnshareLinkOperationFinish(UnshareLinkOperation operation, RemoteOperationResult result) { + private void onUnshareLinkOperationFinish(UnshareLinkOperation operation, + RemoteOperationResult result) { if (result.isSuccess()) { OCFile file = getStorageManager().getFileByPath(getFile().getRemotePath()); if (file != null) { @@ -233,7 +238,8 @@ ViewPager.OnPageChangeListener, OnRemoteOperationListener { } - private void onCreateShareOperationFinish(CreateShareOperation operation, RemoteOperationResult result) { + private void onCreateShareOperationFinish(CreateShareOperation operation, + RemoteOperationResult result) { if (result.isSuccess()) { OCFile file = getStorageManager().getFileByPath(getFile().getRemotePath()); if (file != null) { @@ -254,15 +260,18 @@ ViewPager.OnPageChangeListener, OnRemoteOperationListener { @Override public void onServiceConnected(ComponentName component, IBinder service) { - if (component.equals(new ComponentName(PreviewImageActivity.this, FileDownloader.class))) { + if (component.equals(new ComponentName(PreviewImageActivity.this, + FileDownloader.class))) { mDownloaderBinder = (FileDownloaderBinder) service; if (mRequestWaitingForBinder) { mRequestWaitingForBinder = false; - Log_OC.d(TAG, "Simulating reselection of current page after connection of download binder"); + Log_OC.d(TAG, "Simulating reselection of current page after connection " + + "of download binder"); onPageSelected(mViewPager.getCurrentItem()); } - } else if (component.equals(new ComponentName(PreviewImageActivity.this, FileUploader.class))) { + } else if (component.equals(new ComponentName(PreviewImageActivity.this, + FileUploader.class))) { Log_OC.d(TAG, "Upload service connected"); mUploaderBinder = (FileUploaderBinder) service; } else { @@ -273,10 +282,12 @@ ViewPager.OnPageChangeListener, OnRemoteOperationListener { @Override public void onServiceDisconnected(ComponentName component) { - if (component.equals(new ComponentName(PreviewImageActivity.this, FileDownloader.class))) { + if (component.equals(new ComponentName(PreviewImageActivity.this, + FileDownloader.class))) { Log_OC.d(TAG, "Download service suddenly disconnected"); mDownloaderBinder = null; - } else if (component.equals(new ComponentName(PreviewImageActivity.this, FileUploader.class))) { + } else if (component.equals(new ComponentName(PreviewImageActivity.this, + FileUploader.class))) { Log_OC.d(TAG, "Upload service suddenly disconnected"); mUploaderBinder = null; } @@ -348,7 +359,8 @@ ViewPager.OnPageChangeListener, OnRemoteOperationListener { Intent showDetailsIntent = new Intent(this, FileDisplayActivity.class); showDetailsIntent.setAction(FileDisplayActivity.ACTION_DETAILS); showDetailsIntent.putExtra(FileActivity.EXTRA_FILE, file); - showDetailsIntent.putExtra(FileActivity.EXTRA_ACCOUNT, AccountUtils.getCurrentOwnCloudAccount(this)); + showDetailsIntent.putExtra(FileActivity.EXTRA_ACCOUNT, + AccountUtils.getCurrentOwnCloudAccount(this)); startActivity(showDetailsIntent); int pos = mPreviewImagePagerAdapter.getFilePosition(file); file = mPreviewImagePagerAdapter.getFileAt(pos); @@ -369,9 +381,10 @@ ViewPager.OnPageChangeListener, OnRemoteOperationListener { } /** - * This method will be invoked when a new page becomes selected. Animation is not necessarily complete. + * This method will be invoked when a new page becomes selected. Animation is not necessarily + * complete. * - * @param Position Position index of the new selected page + * @param position Position index of the new selected page */ @Override public void onPageSelected(int position) { @@ -399,20 +412,22 @@ ViewPager.OnPageChangeListener, OnRemoteOperationListener { * Called when the scroll state changes. Useful for discovering when the user begins dragging, * when the pager is automatically settling to the current page. when it is fully stopped/idle. * - * @param State The new scroll state (SCROLL_STATE_IDLE, _DRAGGING, _SETTLING + * @param state The new scroll state (SCROLL_STATE_IDLE, _DRAGGING, _SETTLING */ @Override public void onPageScrollStateChanged(int state) { } /** - * This method will be invoked when the current page is scrolled, either as part of a programmatically - * initiated smooth scroll or a user initiated touch scroll. + * This method will be invoked when the current page is scrolled, either as part of a + * programmatically initiated smooth scroll or a user initiated touch scroll. * * @param position Position index of the first page currently being displayed. - * Page position+1 will be visible if positionOffset is nonzero. + * Page position+1 will be visible if positionOffset is + * nonzero. * - * @param positionOffset Value from [0, 1) indicating the offset from the page at position. + * @param positionOffset Value from [0, 1) indicating the offset from the page + * at position. * @param positionOffsetPixels Value in pixels indicating the offset from position. */ @Override @@ -436,17 +451,21 @@ ViewPager.OnPageChangeListener, OnRemoteOperationListener { OCFile file = getStorageManager().getFileByPath(downloadedRemotePath); int position = mPreviewImagePagerAdapter.getFilePosition(file); - boolean downloadWasFine = intent.getBooleanExtra(FileDownloader.EXTRA_DOWNLOAD_RESULT, false); - //boolean isOffscreen = Math.abs((mViewPager.getCurrentItem() - position)) <= mViewPager.getOffscreenPageLimit(); + boolean downloadWasFine = intent.getBooleanExtra( + FileDownloader.EXTRA_DOWNLOAD_RESULT, false); + //boolean isOffscreen = Math.abs((mViewPager.getCurrentItem() - position)) + // <= mViewPager.getOffscreenPageLimit(); - if (position >= 0 && intent.getAction().equals(FileDownloader.getDownloadFinishMessage())) { + if (position >= 0 && + intent.getAction().equals(FileDownloader.getDownloadFinishMessage())) { if (downloadWasFine) { mPreviewImagePagerAdapter.updateFile(position, file); } else { mPreviewImagePagerAdapter.updateWithDownloadError(position); } - mPreviewImagePagerAdapter.notifyDataSetChanged(); // will trigger the creation of new fragments + mPreviewImagePagerAdapter.notifyDataSetChanged(); // will trigger the creation + // of new fragments } else { Log_OC.d(TAG, "Download finished, but the fragment is offscreen"); diff --git a/src/com/owncloud/android/ui/preview/PreviewImageFragment.java b/src/com/owncloud/android/ui/preview/PreviewImageFragment.java index 9d1cd60f..f8f6e10b 100644 --- a/src/com/owncloud/android/ui/preview/PreviewImageFragment.java +++ b/src/com/owncloud/android/ui/preview/PreviewImageFragment.java @@ -39,6 +39,9 @@ import android.os.Bundle; import android.support.v4.app.FragmentStatePagerAdapter; import android.view.Display; import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; @@ -46,9 +49,6 @@ import android.widget.ImageView; import android.widget.ProgressBar; import android.widget.TextView; -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuInflater; -import com.actionbarsherlock.view.MenuItem; import com.owncloud.android.R; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.files.FileMenuFilter; @@ -64,9 +64,11 @@ import third_parties.michaelOrtiz.TouchImageViewCustom; /** * This fragment shows a preview of a downloaded image. * - * Trying to get an instance with NULL {@link OCFile} or ownCloud {@link Account} values will produce an {@link IllegalStateException}. + * Trying to get an instance with NULL {@link OCFile} or ownCloud {@link Account} values will + * produce an {@link IllegalStateException}. * - * If the {@link OCFile} passed is not downloaded, an {@link IllegalStateException} is generated on instantiation too. + * If the {@link OCFile} passed is not downloaded, an {@link IllegalStateException} is generated on + * instantiation too. */ public class PreviewImageFragment extends FileFragment { @@ -93,11 +95,13 @@ public class PreviewImageFragment extends FileFragment { * * When 'imageFile' or 'ocAccount' are null * - * @param imageFile An {@link OCFile} to preview as an image in the fragment + * @param fileToDetail An {@link OCFile} to preview as an image in the fragment * @param ocAccount An ownCloud account; needed to start downloads - * @param ignoreFirstSavedState Flag to work around an unexpected behaviour of {@link FragmentStatePagerAdapter}; TODO better solution + * @param ignoreFirstSavedState Flag to work around an unexpected behaviour of + * {@link FragmentStatePagerAdapter}; TODO better solution */ - public PreviewImageFragment(OCFile fileToDetail, Account ocAccount, boolean ignoreFirstSavedState) { + public PreviewImageFragment(OCFile fileToDetail, Account ocAccount, + boolean ignoreFirstSavedState) { super(fileToDetail); mAccount = ocAccount; mIgnoreFirstSavedState = ignoreFirstSavedState; @@ -107,9 +111,11 @@ public class PreviewImageFragment extends FileFragment { /** * Creates an empty fragment for image previews. * - * MUST BE KEPT: the system uses it when tries to reinstantiate a fragment automatically (for instance, when the device is turned a aside). + * MUST BE KEPT: the system uses it when tries to reinstantiate a fragment automatically + * (for instance, when the device is turned a aside). * - * DO NOT CALL IT: an {@link OCFile} and {@link Account} must be provided for a successful construction + * DO NOT CALL IT: an {@link OCFile} and {@link Account} must be provided for a successful + * construction */ public PreviewImageFragment() { super(); @@ -160,7 +166,8 @@ public class PreviewImageFragment extends FileFragment { super.onActivityCreated(savedInstanceState); if (savedInstanceState != null) { if (!mIgnoreFirstSavedState) { - OCFile file = (OCFile)savedInstanceState.getParcelable(PreviewImageFragment.EXTRA_FILE); + OCFile file = (OCFile)savedInstanceState.getParcelable( + PreviewImageFragment.EXTRA_FILE); setFile(file); mAccount = savedInstanceState.getParcelable(PreviewImageFragment.EXTRA_ACCOUNT); } else { @@ -234,7 +241,7 @@ public class PreviewImageFragment extends FileFragment { getFile(), mContainerActivity.getStorageManager().getAccount(), mContainerActivity, - getSherlockActivity() + getActivity() ); mf.filter(menu); } @@ -348,22 +355,25 @@ public class PreviewImageFragment extends FileFragment { /** * Weak reference to the target {@link ImageView} where the bitmap will be loaded into. * - * Using a weak reference will avoid memory leaks if the target ImageView is retired from memory before the load finishes. + * Using a weak reference will avoid memory leaks if the target ImageView is retired from + * memory before the load finishes. */ private final WeakReference mImageViewRef; /** * Weak reference to the target {@link TextView} where error messages will be written. * - * Using a weak reference will avoid memory leaks if the target ImageView is retired from memory before the load finishes. + * Using a weak reference will avoid memory leaks if the target ImageView is retired from + * memory before the load finishes. */ private final WeakReference mMessageViewRef; /** - * Weak reference to the target {@link Progressbar} shown while the load is in progress. + * Weak reference to the target {@link ProgressBar} shown while the load is in progress. * - * Using a weak reference will avoid memory leaks if the target ImageView is retired from memory before the load finishes. + * Using a weak reference will avoid memory leaks if the target ImageView is retired from + * memory before the load finishes. */ private final WeakReference mProgressWheelRef; @@ -379,7 +389,8 @@ public class PreviewImageFragment extends FileFragment { * * @param imageView Target {@link ImageView} where the bitmap will be loaded into. */ - public LoadBitmapTask(ImageViewCustom imageView, TextView messageView, ProgressBar progressWheel) { + public LoadBitmapTask(ImageViewCustom imageView, TextView messageView, + ProgressBar progressWheel) { mImageViewRef = new WeakReference(imageView); mMessageViewRef = new WeakReference(messageView); mProgressWheelRef = new WeakReference(progressWheel); @@ -509,7 +520,8 @@ public class PreviewImageFragment extends FileFragment { } /** - * Helper method to test if an {@link OCFile} can be passed to a {@link PreviewImageFragment} to be previewed. + * Helper method to test if an {@link OCFile} can be passed to a {@link PreviewImageFragment} + * to be previewed. * * @param file File to test if can be previewed. * @return 'True' if the file can be handled by the fragment. @@ -575,7 +587,8 @@ public class PreviewImageFragment extends FileFragment { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { options.inMutable = false; } - // make a false load of the bitmap - just to be able to read outWidth, outHeight and outMimeType + // make a false load of the bitmap - just to be able to read outWidth, outHeight and + // outMimeType options.inJustDecodeBounds = true; BitmapFactory.decodeFile(storagePath, options); diff --git a/src/com/owncloud/android/ui/preview/PreviewMediaFragment.java b/src/com/owncloud/android/ui/preview/PreviewMediaFragment.java index d82faa59..89f002ff 100644 --- a/src/com/owncloud/android/ui/preview/PreviewMediaFragment.java +++ b/src/com/owncloud/android/ui/preview/PreviewMediaFragment.java @@ -37,6 +37,9 @@ import android.os.Build; import android.os.Bundle; import android.os.IBinder; import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; import android.view.View.OnTouchListener; @@ -45,9 +48,6 @@ import android.widget.ImageView; import android.widget.Toast; import android.widget.VideoView; -import com.actionbarsherlock.view.Menu; -import com.actionbarsherlock.view.MenuInflater; -import com.actionbarsherlock.view.MenuItem; import com.owncloud.android.R; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.files.FileMenuFilter; @@ -64,9 +64,11 @@ import com.owncloud.android.ui.fragment.FileFragment; /** * This fragment shows a preview of a downloaded media file (audio or video). * - * Trying to get an instance with NULL {@link OCFile} or ownCloud {@link Account} values will produce an {@link IllegalStateException}. + * Trying to get an instance with NULL {@link OCFile} or ownCloud {@link Account} values will + * produce an {@link IllegalStateException}. * - * By now, if the {@link OCFile} passed is not downloaded, an {@link IllegalStateException} is generated on instantiation too. + * By now, if the {@link OCFile} passed is not downloaded, an {@link IllegalStateException} is + * generated on instantiation too. */ public class PreviewMediaFragment extends FileFragment implements OnTouchListener { @@ -251,9 +253,9 @@ public class PreviewMediaFragment extends FileFragment implements private void stopAudio() { - Intent i = new Intent(getSherlockActivity(), MediaService.class); + Intent i = new Intent(getActivity(), MediaService.class); i.setAction(MediaService.ACTION_STOP_ALL); - getSherlockActivity().startService(i); + getActivity().startService(i); } @@ -279,7 +281,7 @@ public class PreviewMediaFragment extends FileFragment implements getFile(), mContainerActivity.getStorageManager().getAccount(), mContainerActivity, - getSherlockActivity() + getActivity() ); mf.filter(menu); } @@ -393,7 +395,7 @@ public class PreviewMediaFragment extends FileFragment implements * * Just starts the playback. * - * @param mp {@link MediaPlayer} instance performing the playback. + * @param vp {@link MediaPlayer} instance performing the playback. */ @Override public void onPrepared(MediaPlayer vp) { @@ -449,8 +451,8 @@ public class PreviewMediaFragment extends FileFragment implements public boolean onError(MediaPlayer mp, int what, int extra) { if (mVideoPreview.getWindowToken() != null) { String message = MediaService.getMessageForMediaError( - getSherlockActivity(), what, extra); - new AlertDialog.Builder(getSherlockActivity()) + getActivity(), what, extra); + new AlertDialog.Builder(getActivity()) .setMessage(message) .setPositiveButton(android.R.string.VideoView_error_button, new DialogInterface.OnClickListener() { @@ -496,7 +498,7 @@ public class PreviewMediaFragment extends FileFragment implements if (mMediaServiceBinder != null && mMediaController != null) { mMediaServiceBinder.unregisterMediaController(mMediaController); } - getSherlockActivity().unbindService(mMediaServiceConnection); + getActivity().unbindService(mMediaServiceConnection); mMediaServiceConnection = null; mMediaServiceBinder = null; } @@ -515,7 +517,7 @@ public class PreviewMediaFragment extends FileFragment implements private void startFullScreenVideo() { - Intent i = new Intent(getSherlockActivity(), PreviewVideoActivity.class); + Intent i = new Intent(getActivity(), PreviewVideoActivity.class); i.putExtra(FileActivity.EXTRA_ACCOUNT, mAccount); i.putExtra(FileActivity.EXTRA_FILE, getFile()); i.putExtra(PreviewVideoActivity.EXTRA_AUTOPLAY, mVideoPreview.isPlaying()); @@ -561,7 +563,7 @@ public class PreviewMediaFragment extends FileFragment implements if (mMediaServiceConnection == null) { mMediaServiceConnection = new MediaServiceConnection(); } - getSherlockActivity().bindService( new Intent(getSherlockActivity(), + getActivity().bindService( new Intent(getActivity(), MediaService.class), mMediaServiceConnection, Context.BIND_AUTO_CREATE); @@ -573,9 +575,9 @@ public class PreviewMediaFragment extends FileFragment implements @Override public void onServiceConnected(ComponentName component, IBinder service) { - if (getSherlockActivity() != null) { + if (getActivity() != null) { if (component.equals( - new ComponentName(getSherlockActivity(), MediaService.class))) { + new ComponentName(getActivity(), MediaService.class))) { Log_OC.d(TAG, "Media service connected"); mMediaServiceBinder = (MediaServiceBinder) service; if (mMediaServiceBinder != null) { @@ -602,13 +604,13 @@ public class PreviewMediaFragment extends FileFragment implements @Override public void onServiceDisconnected(ComponentName component) { - if (component.equals(new ComponentName(getSherlockActivity(), MediaService.class))) { + if (component.equals(new ComponentName(getActivity(), MediaService.class))) { Log_OC.e(TAG, "Media service suddenly disconnected"); if (mMediaController != null) { mMediaController.setMediaPlayer(null); } else { Toast.makeText( - getSherlockActivity(), + getActivity(), "No media controller to release when disconnected from media service", Toast.LENGTH_SHORT).show(); } @@ -657,7 +659,7 @@ public class PreviewMediaFragment extends FileFragment implements * Finishes the preview */ private void finish() { - getSherlockActivity().onBackPressed(); + getActivity().onBackPressed(); }