}
}
-artifacts.add("default", file('libs/actionbarsherlock.aar'))
-
dependencies {
compile name: 'touch-image-view'
compile 'com.android.support:support-v4:19.1.0'
- compile project('libs/actionbarsherlock_lib')
compile project(':owncloud-android-library')
compile 'com.jakewharton:disklrucache:2.0.2'
+ compile 'com.android.support:appcompat-v7:22.1.1'
}
android {
- compileSdkVersion 19
+ compileSdkVersion 21
buildToolsVersion "20.0.0"
sourceSets {
main {
+++ /dev/null
-configurations.create("default")
-artifacts.add("default", file('library-4.1.0.aar'))
<style name="Animations" />
<!-- General ownCloud app style -->
- <style name="Theme.ownCloud" parent="style/Theme.Sherlock.Light.DarkActionBar">
+ <style name="Theme.ownCloud" parent="style/Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarStyle">@style/Theme.ownCloud.Widget.ActionBar</item>
<item name="actionBarStyle">@style/Theme.ownCloud.Widget.ActionBar</item>
<item name="android:buttonStyle">@style/Theme.ownCloud.ButtonStyle</item>
<item name="android:actionDropDownStyle">@style/Theme.ownCloud.DropDownStyle</item>
</style>
- <style name="Theme.ownCloud.noActionBar" parent="style/Theme.Sherlock.Light.NoActionBar">
+ <style name="Theme.ownCloud.noActionBar" parent="style/Theme.AppCompat.Light.NoActionBar">
<item name="android:actionBarStyle">@style/Theme.ownCloud.Widget.ActionBar</item>
<item name="actionBarStyle">@style/Theme.ownCloud.Widget.ActionBar</item>
<item name="android:buttonStyle">@style/Theme.ownCloud.ButtonStyle</item>
<item name="android:actionDropDownStyle">@style/Theme.ownCloud.DropDownStyle</item>
</style>
- <style name="Theme.ownCloud.Fullscreen" parent="style/Theme.Sherlock.NoActionBar">
+ <style name="Theme.ownCloud.Fullscreen" parent="style/Theme.AppCompat.NoActionBar">
<item name="android:actionBarStyle">@style/Theme.ownCloud.Widget.ActionBar</item>
<item name="actionBarStyle">@style/Theme.ownCloud.Widget.ActionBar</item>
<item name="android:windowFullscreen">true</item>
</style>
- <style name="Theme.ownCloud.Widget.ActionBar" parent="style/Widget.Sherlock.Light.ActionBar.Solid.Inverse">
+ <style name="Theme.ownCloud.Widget.ActionBar"
+ parent="style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="android:background">@drawable/main_header_bg</item>
<item name="background">@drawable/main_header_bg</item>
<item name="android:textColor">#ffffff</item>
<item name="android:shadowRadius">1</item>
<item name="android:shadowDy">1</item>
<item name="android:backgroundSplit">@drawable/split_action_bg</item>
- <item name="android:indeterminateProgressStyle">@style/Theme.ownCloud.IndeterminateStyle</item>
+ <item name="android:indeterminateProgressStyle">
+ @style/Theme.ownCloud.IndeterminateStyle
+ </item>
<item name="indeterminateProgressStyle">@style/Theme.ownCloud.IndeterminateStyle</item>
</style>
</style>
<!-- DropDown -->
- <style name="Theme.ownCloud.DropDownStyle" parent="style/Widget.Sherlock.Spinner.DropDown.ActionBar">
- <item name="android:background">@drawable/abs__spinner_ab_holo_dark</item>
+ <style name="Theme.ownCloud.DropDownStyle"
+ parent="style/Widget.AppCompat.Spinner.DropDown.ActionBar">
+ <!-- <item name="android:background">@drawable/abs__spinner_ab_holo_dark</item> -->
+ <item name="android:background">@drawable/spinner_inner</item>
</style>
- <style name="Theme.ownCloud.IndeterminateStyle" parent="style/Widget.Sherlock.ProgressBar">
- <item name="android:indeterminateDrawable">@drawable/abs__progress_medium_holo</item>
+ <style name="Theme.ownCloud.IndeterminateStyle"
+ parent="style/Widget.AppCompat.ProgressBar">
+ <!--<item name="android:indeterminateDrawable">@drawable/abs__progress_medium_holo</item>-->
+ <item name="android:indeterminateDrawable">@drawable/progress_small</item>
</style>
<!-- Notifications -->
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.
* 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;
import android.os.Handler;\r
import android.os.IBinder;\r
import android.preference.PreferenceManager;\r
+import android.support.v4.app.DialogFragment;\r
import android.support.v4.app.Fragment;\r
import android.support.v4.app.FragmentManager;\r
import android.support.v4.app.FragmentTransaction;\r
import android.widget.TextView.OnEditorActionListener;\r
import android.widget.Toast;\r
\r
-import com.actionbarsherlock.app.SherlockDialogFragment;\r
import com.owncloud.android.MainApp;\r
import com.owncloud.android.R;\r
import com.owncloud.android.authentication.SsoWebViewClient.SsoWebViewClientListener;\r
/// Identifier of operation in progress which result shouldn't be lost \r
private long mWaitingForOpId = Long.MAX_VALUE;\r
\r
- private final String BASIC_TOKEN_TYPE = AccountTypeUtils.getAuthTokenTypePass(MainApp.getAccountType());\r
- private final String OAUTH_TOKEN_TYPE = AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType());\r
+ private final String BASIC_TOKEN_TYPE = AccountTypeUtils.getAuthTokenTypePass(\r
+ MainApp.getAccountType());\r
+ private final String OAUTH_TOKEN_TYPE = AccountTypeUtils.getAuthTokenTypeAccessToken(\r
+ MainApp.getAccountType());\r
private final String SAML_TOKEN_TYPE =\r
AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType());\r
\r
protected void onCreate(Bundle savedInstanceState) {\r
//Log_OC.wtf(TAG, "onCreate init");\r
super.onCreate(savedInstanceState);\r
- getWindow().requestFeature(Window.FEATURE_NO_TITLE);\r
+ //getWindow().requestFeature(Window.FEATURE_NO_TITLE);\r
\r
mIsFirstAuthAttempt = true;\r
\r
dialog.show(getSupportFragmentManager(), WAIT_DIALOG_TAG);\r
\r
/// validate credentials accessing the root folder\r
- OwnCloudCredentials credentials = OwnCloudCredentialsFactory.newBasicCredentials(username, password);\r
+ OwnCloudCredentials credentials = OwnCloudCredentialsFactory.newBasicCredentials(username,\r
+ password);\r
accessRootFolder(credentials);\r
}\r
\r
\r
} catch (AccountNotFoundException e) {\r
Log_OC.e(TAG, "Account " + mAccount + " was removed!", e);\r
- Toast.makeText(this, R.string.auth_account_does_not_exist, Toast.LENGTH_SHORT).show();\r
+ Toast.makeText(this, R.string.auth_account_does_not_exist,\r
+ Toast.LENGTH_SHORT).show();\r
finish();\r
}\r
}\r
Log_OC.d(TAG, "Got ACCESS TOKEN: " + mAuthToken);\r
\r
/// validate token accessing to root folder / getting session\r
- OwnCloudCredentials credentials = OwnCloudCredentialsFactory.newBearerCredentials(mAuthToken);\r
+ OwnCloudCredentials credentials = OwnCloudCredentialsFactory.newBearerCredentials(\r
+ mAuthToken);\r
accessRootFolder(credentials);\r
\r
} else {\r
\r
} catch (AccountNotFoundException e) {\r
Log_OC.e(TAG, "Account " + mAccount + " was removed!", e);\r
- Toast.makeText(this, R.string.auth_account_does_not_exist, Toast.LENGTH_SHORT).show();\r
+ Toast.makeText(this, R.string.auth_account_does_not_exist,\r
+ Toast.LENGTH_SHORT).show();\r
finish();\r
}\r
}\r
mAuthToken = sessionCookie;\r
getRemoteUserNameOperation(sessionCookie, true);\r
Fragment fd = getSupportFragmentManager().findFragmentByTag(SAML_DIALOG_TAG);\r
- if (fd != null && fd instanceof SherlockDialogFragment) {\r
- Dialog d = ((SherlockDialogFragment)fd).getDialog();\r
+ if (fd != null && fd instanceof DialogFragment) {\r
+ Dialog d = ((DialogFragment)fd).getDialog();\r
if (d != null && d.isShowing()) {\r
d.dismiss();\r
}\r
\r
private void dismissDialog(String dialogTag){\r
Fragment frag = getSupportFragmentManager().findFragmentByTag(dialogTag);\r
- if (frag != null && frag instanceof SherlockDialogFragment) {\r
- SherlockDialogFragment dialog = (SherlockDialogFragment) frag;\r
+ if (frag != null && frag instanceof DialogFragment) {\r
+ DialogFragment dialog = (DialogFragment) frag;\r
dialog.dismiss();\r
}\r
}\r
}
}
- /**
- * 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<Integer> toShow = new ArrayList<Integer>();
- List<Integer> toHide = new ArrayList<Integer>();
-
- 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.
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;
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;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- ActionBar actionBar = getSupportActionBar();
+ ActionBar actionBar = getActionBar();
actionBar.setIcon(DisplayUtils.getSeasonalIconId());
}
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;
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;
/**
- * 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";
/// 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());
/**
- * 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<String> {
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
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) {
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) {
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();
}
}
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;
/**
- * 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();
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 */
} 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);
}
}
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;
/**
- * 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;
*/
@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);
}
- 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();
}
}
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();
}
}
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();
}
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;
*/
public class FileDisplayActivity extends HookActivity implements
-FileFragment.ContainerActivity, OnNavigationListener,
-OnSslUntrustedCertListener, OnEnforceableRefreshListener {
+ FileFragment.ContainerActivity, ActionBar.OnNavigationListener,
+ OnSslUntrustedCertListener, OnEnforceableRefreshListener {
private ArrayAdapter<String> mDirectories;
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) {
/// 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;
}
// Action bar setup
- mDirectories = new CustomArrayAdapter<String>(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<String>(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();
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) {
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);
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());
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;
}
}
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;
}
}
}
- 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;
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;
@Override
public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getSherlock().getMenuInflater();
+ MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_menu, menu);
return true;
}
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);
// 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;
@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++){
}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){
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;
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, '_');
@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");
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());
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) {
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();
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);
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) &&
}
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;
}
}
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) ||
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();
}
if (mWaitingToSend != null) {
- mWaitingToSend = getStorageManager().getFileByPath(mWaitingToSend.getRemotePath());
+ mWaitingToSend =
+ getStorageManager().getFileByPath(mWaitingToSend.getRemotePath());
if (mWaitingToSend.isDown()) {
sendDownloadedFile();
}
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));
}
}
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);
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();
@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;
}
}
- private void onCreateShareOperationFinish(CreateShareOperation operation, RemoteOperationResult result) {
+ private void onCreateShareOperationFinish(CreateShareOperation operation,
+ RemoteOperationResult result) {
if (result.isSuccess()) {
refreshShowDetails();
refreshListOfFilesFragment();
}
- private void onUnshareLinkOperationFinish(UnshareLinkOperation operation, RemoteOperationResult result) {
+ private void onUnshareLinkOperationFinish(UnshareLinkOperation operation,
+ RemoteOperationResult result) {
if (result.isSuccess()) {
refreshShowDetails();
refreshListOfFilesFragment();
}
/**
- * 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();
* @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();
/**
- * 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();
}
}
- 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();
}
}
- private void onSynchronizeFileOperationFinish(SynchronizeFileOperation operation, RemoteOperationResult result) {
+ private void onSynchronizeFileOperationFinish(SynchronizeFileOperation operation,
+ RemoteOperationResult result) {
dismissLoadingDialog();
OCFile syncedFile = operation.getLocalFile();
if (!result.isSuccess()) {
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();
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 {
// 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);
* 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);
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;
@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);
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;
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;
* 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
ListView listView = (ListView) findViewById(R.id.list);
if (list != null && list.size() > 0) {
- //ListAdapter adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list);
+ //ListAdapter adapter = new ArrayAdapter<String>(this,
+ // android.R.layout.simple_list_item_1, list);
ListAdapter adapter = new ExplanationListAdapterView(this, list, list2);
listView.setAdapter(adapter);
} else {
ArrayList<String> mList;
ArrayList<String> mList2;
- ExplanationListAdapterView(Context context, ArrayList<String> list, ArrayList<String> list2) {
+ ExplanationListAdapterView(Context context, ArrayList<String> list,
+ ArrayList<String> list2) {
super(context, android.R.layout.two_line_list_item, android.R.id.text1, list);
mList = list;
mList2 = list2;
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));
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;
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";
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);
}
@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;
}
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;
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();
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;
/**
* An Activity that allows the user to change the application's settings.
*/
-public class Preferences extends SherlockPreferenceActivity
+public class Preferences extends PreferenceActivity
implements AccountManagerCallback<Boolean>, ComponentsGetter {
private static final String TAG = "OwnCloudPreferences";
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");
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;
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;
*/
public class UploadFilesActivity extends FileActivity implements
- LocalFileListFragment.ContainerActivity, OnNavigationListener, OnClickListener, ConfirmationDialogFragmentListener {
+ LocalFileListFragment.ContainerActivity, ActionBar.OnNavigationListener,
+ OnClickListener, ConfirmationDialogFragmentListener {
private ArrayAdapter<String> mDirectories;
private File mCurrentDir = null;
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();
}
/// USER INTERFACE
// Drop-down navigation
- mDirectories = new CustomArrayAdapter<String>(this, R.layout.sherlock_spinner_dropdown_item);
+ mDirectories = new CustomArrayAdapter<String>(this,
+ R.layout.support_simple_spinner_dropdown_item);
File currDir = mCurrentDir;
while(currDir != null && currDir.getParentFile() != null) {
mDirectories.add(currDir.getName());
// 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
// 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);
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;
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;
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
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;
/**
* 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) {
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());
* {@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);
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";
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;
/**
* 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,
@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))
.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) {
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();
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;
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;
*
* 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";
/**
* 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) {
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
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)
if (newFolderName.length() <= 0) {
Toast.makeText(
- getSherlockActivity(),
+ getActivity(),
R.string.filename_empty,
Toast.LENGTH_LONG).show();
return;
if (!FileUtils.isValidName(newFolderName)) {
Toast.makeText(
- getSherlockActivity(),
+ getActivity(),
R.string.filename_forbidden_characters,
Toast.LENGTH_LONG).show();
return;
String path = mParentFolder.getRemotePath();
path += newFolderName + OCFile.PATH_SEPARATOR;
- ((ComponentsGetter)getSherlockActivity()).
+ ((ComponentsGetter)getActivity()).
getFileOperationsHelper().createFolder(path, false);
}
}
package com.owncloud.android.ui.dialog;
-import com.actionbarsherlock.app.SherlockDialogFragment;
import com.owncloud.android.R;
import com.owncloud.android.authentication.AuthenticatorActivity;
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;
* Dialog to input authentication credentials
*
*/
-public class CredentialsDialogFragment extends SherlockDialogFragment
+public class CredentialsDialogFragment extends DialogFragment
implements DialogInterface.OnClickListener {
private WebView mWebView = null;
* @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;
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);
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)
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";
*/
@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);
*/
@Override
public void onNeutral(String callerTag) {
- ComponentsGetter cg = (ComponentsGetter)getSherlockActivity();
+ ComponentsGetter cg = (ComponentsGetter)getActivity();
cg.getFileOperationsHelper().removeFile(mTargetFile, true);
FileDataStorageManager storageManager = cg.getStorageManager();
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;
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;
* 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";
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
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)
if (newFileName.length() <= 0) {
Toast.makeText(
- getSherlockActivity(),
+ getActivity(),
R.string.filename_empty,
Toast.LENGTH_LONG).show();
return;
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);
}
}
}
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;
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;
/**
* 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";
* 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) {
setRetainInstance(true);
- CookieSyncManager.createInstance(getSherlockActivity().getApplicationContext());
+ CookieSyncManager.createInstance(getActivity().getApplicationContext());
if (savedInstanceState == null) {
mInitialUrl = getArguments().getString(ARG_INITIAL_URL);
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")
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);
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;
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;
* 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);
public Dialog onCreateDialog(Bundle savedInstanceState) {
mIntent = getArguments().getParcelable(ARG_INTENT);
String[] packagesToExclude = getArguments().getStringArray(ARG_PACKAGES_TO_EXCLUDE);
- List<String> packagesToExcludeList = Arrays.asList(packagesToExclude != null ? packagesToExclude : new String[0]);
+ List<String> packagesToExcludeList = Arrays.asList(packagesToExclude != null ?
+ packagesToExclude : new String[0]);
mFile = getArguments().getParcelable(ARG_FILE_TO_SHARE);
- PackageManager pm= getSherlockActivity().getPackageManager();
- List<ResolveInfo> activities = pm.queryIntentActivities(mIntent, PackageManager.MATCH_DEFAULT_ONLY);
+ PackageManager pm= getActivity().getPackageManager();
+ List<ResolveInfo> activities = pm.queryIntentActivities(mIntent,
+ PackageManager.MATCH_DEFAULT_ONLY);
Iterator<ResolveInfo> 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();
}
}
if (!sendAction) {
// add activity for copy to clipboard
- Intent copyToClipboardIntent = new Intent(getSherlockActivity(), CopyToClipboardActivity.class);
+ Intent copyToClipboardIntent = new Intent(getActivity(), CopyToClipboardActivity.class);
List<ResolveInfo> copyToClipboard = pm.queryIntentActivities(copyToClipboardIntent, 0);
if (!copyToClipboard.isEmpty()) {
activities.add(copyToClipboard.get(0));
}
Collections.sort(activities, new ResolveInfo.DisplayNameComparator(pm));
- mAdapter = new ActivityAdapter(getSherlockActivity(), pm, activities);
+ mAdapter = new ActivityAdapter(getActivity(), pm, activities);
return createSelector(sendAction);
titleId = R.string.activity_chooser_title;
}
- return new AlertDialog.Builder(getSherlockActivity())
+ return new AlertDialog.Builder(getActivity())
.setTitle(titleId)
.setAdapter(mAdapter, new DialogInterface.OnClickListener() {
@Override
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);
}
}
}
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) {
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;
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;
* 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";
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)))
}
// 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);
}
}
}
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;
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;
* 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();
if (mHandler != null) {
mHandler.cancel();
}
- ((OnSslUntrustedCertListener)getSherlockActivity()).onCancelCertificate();
+ ((OnSslUntrustedCertListener)getActivity()).onCancelCertificate();
}
}
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();
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;
*
* 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;
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);
}
//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
);
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 {
}
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 {
}
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;
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;
/**
* 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();
@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);
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;
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;
getFile(),
mContainerActivity.getStorageManager().getAccount(),
mContainerActivity,
- getSherlockActivity()
+ getActivity()
);
mf.filter(menu);
}
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();
}
}
*/
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) {
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());
}
}
}
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());
}
}
}
/**
- * 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;
}
@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();
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;
/**
* Common methods for {@link Fragment}s containing {@link OCFile}s
*/
-public class FileFragment extends SherlockFragment {
+public class FileFragment extends Fragment {
private OCFile mFile;
/**
* 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;
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());
}
}
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);
*
* 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.
mJustFolders = (args == null) ? false : args.getBoolean(ARG_JUST_FOLDERS, false);
mAdapter = new FileListListAdapter(
mJustFolders,
- getSherlockActivity(),
+ getActivity(),
mContainerActivity
);
setListAdapter(mAdapter);
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);
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);
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;
/**
* Holds a swiping galley where image files contained in an ownCloud directory are shown
*/
-public class PreviewImageActivity extends FileActivity implements
- FileFragment.ContainerActivity,
-ViewPager.OnPageChangeListener, OnRemoteOperationListener {
+public class PreviewImageActivity extends FileActivity implements
+ FileFragment.ContainerActivity,
+ ViewPager.OnPageChangeListener, OnRemoteOperationListener {
public static final int DIALOG_SHORT_WAIT = 0;
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;
}
}
}
- 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) {
}
- 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) {
@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 {
@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;
}
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);
}
/**
- * 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) {
* 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
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");
import android.os.Bundle;
import android.support.v4.app.FragmentStatePagerAdapter;
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;
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;
/**
* This fragment shows a preview of a downloaded image.
+ *
+ * Trying to get an instance with a NULL {@link OCFile} will produce an
+ * {@link IllegalStateException}.
*
- * Trying to get an instance with a NULL {@link OCFile} 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 {
/**
* Public factory method to create a new fragment that previews an image.
*
- * Android strongly recommends keep the empty constructor of fragments as the only public constructor, and
+ * Android strongly recommends keep the empty constructor of fragments as the only public
+ * constructor, and
* use {@link #setArguments(Bundle)} to set the needed arguments.
*
* This method hides to client objects the need of doing the construction in two steps.
*
* @param imageFile An {@link OCFile} to preview as an image in the fragment
- * @param ignoreFirstSavedState Flag to work around an unexpected behaviour of {@link FragmentStatePagerAdapter}
+ * @param ignoreFirstSavedState Flag to work around an unexpected behaviour of
+ * {@link FragmentStatePagerAdapter}
* ; TODO better solution
*/
- public static PreviewImageFragment newInstance(OCFile imageFile, boolean ignoreFirstSavedState) {
+ public static PreviewImageFragment newInstance(OCFile imageFile, boolean ignoreFirstSavedState){
PreviewImageFragment frag = new PreviewImageFragment();
Bundle args = new Bundle();
args.putParcelable(ARG_FILE, imageFile);
* 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() {
mIgnoreFirstSavedState = false;
super.onCreate(savedInstanceState);
Bundle args = getArguments();
setFile((OCFile)args.getParcelable(ARG_FILE));
- // TODO better in super, but needs to check ALL the class extending FileFragment; not right now
+ // TODO better in super, but needs to check ALL the class extending FileFragment;
+ // not right now
mIgnoreFirstSavedState = args.getBoolean(ARG_IGNORE_FIRST);
setHasOptionsMenu(true);
getFile(),
mContainerActivity.getStorageManager().getAccount(),
mContainerActivity,
- getSherlockActivity()
+ getActivity()
);
mf.filter(menu);
}
mBitmap.recycle();
System.gc();
// putting this in onStop() is just the same; the fragment is always destroyed by
- // {@link FragmentStatePagerAdapter} when the fragment in swiped further than the valid offscreen
- // distance, and onStop() is never called before than that
+ // {@link FragmentStatePagerAdapter} when the fragment in swiped further than the
+ // valid offscreen distance, and onStop() is never called before than that
}
super.onDestroy();
}
/**
* 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<ImageViewCustom> 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<TextView> mMessageViewRef;
/**
* 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<ProgressBar> mProgressWheelRef;
*
* @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<ImageViewCustom>(imageView);
mMessageViewRef = new WeakReference<TextView>(messageView);
mProgressWheelRef = new WeakReference<ProgressBar>(progressWheel);
for (int i = 0; i < maxDownScale && result == null; i++) {
if (isCancelled()) return null;
try {
- result = BitmapUtils.decodeSampledBitmapFromFile(storagePath, minWidth, minHeight);
+ result = BitmapUtils.decodeSampledBitmapFromFile(storagePath, minWidth,
+ minHeight);
if (isCancelled()) return result;
} catch (OutOfMemoryError e) {
mErrorMessageId = R.string.common_error_out_memory;
if (i < maxDownScale - 1) {
- Log_OC.w(TAG, "Out of memory rendering file " + storagePath + " ; scaling down");
+ Log_OC.w(TAG, "Out of memory rendering file " + storagePath +
+ " ; scaling down");
minWidth = minWidth / 2;
minHeight = minHeight / 2;
} else {
- Log_OC.w(TAG, "Out of memory rendering file " + storagePath + " ; failing");
+ Log_OC.w(TAG, "Out of memory rendering file " + storagePath +
+ " ; failing");
}
if (result != null) {
result.recycle();
private void showLoadedImage(Bitmap result) {
final ImageViewCustom imageView = mImageViewRef.get();
if (imageView != null) {
- Log_OC.d(TAG, "Showing image with resolution " + result.getWidth() + "x" + result.getHeight());
+ Log_OC.d(TAG, "Showing image with resolution " + result.getWidth() + "x" +
+ result.getHeight());
imageView.setImageBitmap(result);
imageView.setVisibility(View.VISIBLE);
mBitmap = result; // needs to be kept for recycling when not useful
}
/**
- * 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.
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;
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;
/**
* 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 {
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);
}
getFile(),
mContainerActivity.getStorageManager().getAccount(),
mContainerActivity,
- getSherlockActivity()
+ getActivity()
);
mf.filter(menu);
}
*
* 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) {
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() {
if (mMediaServiceBinder != null && mMediaController != null) {
mMediaServiceBinder.unregisterMediaController(mMediaController);
}
- getSherlockActivity().unbindService(mMediaServiceConnection);
+ getActivity().unbindService(mMediaServiceConnection);
mMediaServiceConnection = null;
mMediaServiceBinder = null;
}
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());
if (mMediaServiceConnection == null) {
mMediaServiceConnection = new MediaServiceConnection();
}
- getSherlockActivity().bindService( new Intent(getSherlockActivity(),
+ getActivity().bindService( new Intent(getActivity(),
MediaService.class),
mMediaServiceConnection,
Context.BIND_AUTO_CREATE);
@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) {
@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();
}
* Finishes the preview
*/
private void finish() {
- getSherlockActivity().onBackPressed();
+ getActivity().onBackPressed();
}