mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 13:45:35 +03:00
rebase fixes
This commit is contained in:
parent
576b7b11dc
commit
bf3deb49a2
6 changed files with 67 additions and 52 deletions
|
@ -27,19 +27,16 @@
|
|||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
<<<<<<< HEAD
|
||||
android:background="@color/background_color">
|
||||
=======
|
||||
android:orientation="vertical">
|
||||
|
||||
<include
|
||||
layout="@layout/toolbar_standard"/>
|
||||
>>>>>>> layout fix due to added toolbar + oC license added
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/upload_list_fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/background_color"/>
|
||||
</LinearLayout>
|
||||
|
||||
<include
|
||||
|
|
|
@ -21,13 +21,10 @@ package com.owncloud.android.ui.activity;
|
|||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.accounts.AccountManagerCallback;
|
||||
import android.accounts.AccountManagerFuture;
|
||||
import android.accounts.OperationCanceledException;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.design.widget.NavigationView;
|
||||
import android.support.v4.view.GravityCompat;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
|
@ -37,15 +34,12 @@ import android.view.MenuItem;
|
|||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.authentication.AccountUtils;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.status.OCCapability;
|
||||
import com.owncloud.android.ui.TextDrawable;
|
||||
import com.owncloud.android.utils.BitmapUtils;
|
||||
|
||||
|
@ -114,14 +108,12 @@ public abstract class DrawerActivity extends ToolbarActivity {
|
|||
if (mIsAccountChooserActive) {
|
||||
toggleAccountList();
|
||||
}
|
||||
updateActionBarTitleAndHomeButton(null);
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
/** Called when a drawer has settled in a completely open state. */
|
||||
public void onDrawerOpened(View drawerView) {
|
||||
super.onDrawerOpened(drawerView);
|
||||
getSupportActionBar().setTitle(R.string.app_name);
|
||||
mDrawerToggle.setDrawerIndicatorEnabled(true);
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
|
@ -129,7 +121,8 @@ public abstract class DrawerActivity extends ToolbarActivity {
|
|||
|
||||
// Set the drawer toggle as the DrawerListener
|
||||
mDrawerLayout.setDrawerListener(mDrawerToggle);
|
||||
mDrawerToggle.setDrawerIndicatorEnabled(false);
|
||||
mDrawerToggle.setDrawerIndicatorEnabled(true);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -149,6 +142,12 @@ public abstract class DrawerActivity extends ToolbarActivity {
|
|||
menuItem.setChecked(true);
|
||||
allFilesOption();
|
||||
break;
|
||||
case R.id.nav_uploads:
|
||||
Intent uploadListIntent = new Intent(getApplicationContext(),
|
||||
UploadListActivity.class);
|
||||
uploadListIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(uploadListIntent);
|
||||
break;
|
||||
case R.id.nav_settings:
|
||||
Intent settingsIntent = new Intent(getApplicationContext(),
|
||||
Preferences.class);
|
||||
|
@ -380,7 +379,6 @@ public abstract class DrawerActivity extends ToolbarActivity {
|
|||
if (mDrawerToggle != null) {
|
||||
mDrawerToggle.syncState();
|
||||
if (isDrawerOpen()) {
|
||||
getSupportActionBar().setTitle(R.string.app_name);
|
||||
mDrawerToggle.setDrawerIndicatorEnabled(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* @author David A. Velasco
|
||||
* Copyright (C) 2011 Bartek Przybylski
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
* Copyright (C) 2016 ownCloud Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
|
@ -91,6 +91,9 @@ public class FileActivity extends DrawerActivity
|
|||
private static final String KEY_WAITING_FOR_OP_ID = "WAITING_FOR_OP_ID";
|
||||
private static final String KEY_ACTION_BAR_TITLE = "ACTION_BAR_TITLE";
|
||||
|
||||
public static final int REQUEST_CODE__UPDATE_CREDENTIALS = 0;
|
||||
public static final int REQUEST_CODE__LAST_SHARED = REQUEST_CODE__UPDATE_CREDENTIALS;
|
||||
|
||||
protected static final long DELAY_TO_REQUEST_OPERATIONS_LATER = 200;
|
||||
|
||||
/* Dialog tags */
|
||||
|
@ -277,7 +280,7 @@ public class FileActivity extends DrawerActivity
|
|||
|
||||
/**
|
||||
*
|
||||
* @param operation Removal operation performed.
|
||||
* @param operation Operation performed.
|
||||
* @param result Result of the removal.
|
||||
*/
|
||||
@Override
|
||||
|
@ -291,14 +294,12 @@ public class FileActivity extends DrawerActivity
|
|||
|
||||
if (!result.isSuccess() && (
|
||||
result.getCode() == ResultCode.UNAUTHORIZED ||
|
||||
result.isIdPRedirection() ||
|
||||
(result.isException() && result.getException() instanceof AuthenticatorException)
|
||||
)) {
|
||||
|
||||
requestCredentialsUpdate(this);
|
||||
|
||||
if (result.getCode() == ResultCode.UNAUTHORIZED) {
|
||||
dismissLoadingDialog();
|
||||
Toast t = Toast.makeText(this, ErrorMessageAdapter.getErrorCauseMessage(result,
|
||||
operation, getResources()),
|
||||
Toast.LENGTH_LONG);
|
||||
|
@ -346,16 +347,34 @@ public class FileActivity extends DrawerActivity
|
|||
* Invalidates the credentials stored for the current OC account and requests new credentials to the user,
|
||||
* navigating to {@link AuthenticatorActivity}
|
||||
*
|
||||
* Equivalent to call requestCredentialsUpdate(context, null);
|
||||
*
|
||||
* @param context Android Context needed to access the {@link AccountManager}. Received as a parameter
|
||||
* to make the method accessible to {@link android.content.BroadcastReceiver}s.
|
||||
*/
|
||||
protected void requestCredentialsUpdate(Context context) {
|
||||
requestCredentialsUpdate(context, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidates the credentials stored for the given OC account and requests new credentials to the user,
|
||||
* navigating to {@link AuthenticatorActivity}
|
||||
*
|
||||
* @param context Android Context needed to access the {@link AccountManager}. Received as a parameter
|
||||
* to make the method accessible to {@link android.content.BroadcastReceiver}s.
|
||||
* @param account Stored OC account to request credentials update for. If null, current account will
|
||||
* be used.
|
||||
*/
|
||||
protected void requestCredentialsUpdate(Context context, Account account) {
|
||||
|
||||
try {
|
||||
/// step 1 - invalidate credentials of current account
|
||||
if (account == null) {
|
||||
account = getAccount();
|
||||
}
|
||||
OwnCloudClient client;
|
||||
OwnCloudAccount ocAccount =
|
||||
new OwnCloudAccount(getAccount(), context);
|
||||
new OwnCloudAccount(account, context);
|
||||
client = (OwnCloudClientManagerFactory.getDefaultSingleton().
|
||||
removeClientFor(ocAccount));
|
||||
if (client != null) {
|
||||
|
@ -364,23 +383,23 @@ public class FileActivity extends DrawerActivity
|
|||
AccountManager am = AccountManager.get(context);
|
||||
if (cred.authTokenExpires()) {
|
||||
am.invalidateAuthToken(
|
||||
getAccount().type,
|
||||
account.type,
|
||||
cred.getAuthToken()
|
||||
);
|
||||
} else {
|
||||
am.clearPassword(getAccount());
|
||||
am.clearPassword(account);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// step 2 - request credentials to user
|
||||
Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class);
|
||||
updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, getAccount());
|
||||
updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, account);
|
||||
updateAccountCredentials.putExtra(
|
||||
AuthenticatorActivity.EXTRA_ACTION,
|
||||
AuthenticatorActivity.ACTION_UPDATE_EXPIRED_TOKEN);
|
||||
updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
||||
startActivity(updateAccountCredentials);
|
||||
startActivityForResult(updateAccountCredentials, REQUEST_CODE__UPDATE_CREDENTIALS);
|
||||
|
||||
} catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException e) {
|
||||
Toast.makeText(context, R.string.auth_account_does_not_exist, Toast.LENGTH_SHORT).show();
|
||||
|
@ -516,6 +535,13 @@ public class FileActivity extends DrawerActivity
|
|||
}
|
||||
|
||||
@Override
|
||||
|
||||
public void restart(){
|
||||
Intent i = new Intent(this, FileDisplayActivity.class);
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(i);
|
||||
}
|
||||
|
||||
public void allFilesOption(){
|
||||
restart();
|
||||
}
|
||||
|
|
|
@ -515,7 +515,7 @@ public class FileDisplayActivity extends HookActivity
|
|||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
boolean drawerOpen = mDrawerLayout.isDrawerOpen(GravityCompat.START);
|
||||
boolean drawerOpen = isDrawerOpen();
|
||||
menu.findItem(R.id.action_sort).setVisible(!drawerOpen);
|
||||
menu.findItem(R.id.action_sync_account).setVisible(!drawerOpen);
|
||||
menu.findItem(R.id.action_switch_view).setVisible(!drawerOpen);
|
||||
|
@ -543,14 +543,14 @@ public class FileDisplayActivity extends HookActivity
|
|||
case android.R.id.home: {
|
||||
FileFragment second = getSecondFragment();
|
||||
OCFile currentDir = getCurrentDir();
|
||||
if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
|
||||
mDrawerLayout.closeDrawer(GravityCompat.START);
|
||||
if (isDrawerOpen()) {
|
||||
closeDrawer();
|
||||
} else if ((currentDir != null && currentDir.getParentId() != 0) ||
|
||||
(second != null && second.getFile() != null)) {
|
||||
onBackPressed();
|
||||
|
||||
} else {
|
||||
mDrawerLayout.openDrawer(GravityCompat.START);
|
||||
openDrawer();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* @author Bartek Przybylski
|
||||
* @author David A. Velasco
|
||||
* Copyright (C) 2011 Bartek Przybylski
|
||||
* Copyright (C) 2015 ownCloud Inc.
|
||||
* Copyright (C) 2016 ownCloud Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2,
|
||||
|
@ -52,7 +52,6 @@ import com.owncloud.android.BuildConfig;
|
|||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.authentication.AccountUtils;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.db.DbHandler;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
|
||||
|
@ -72,7 +71,6 @@ public class Preferences extends PreferenceActivity {
|
|||
private static final int ACTION_REQUEST_PASSCODE = 5;
|
||||
private static final int ACTION_CONFIRM_PASSCODE = 6;
|
||||
|
||||
private DbHandler mDbHandler;
|
||||
private CheckBoxPreference pCode;
|
||||
private Preference pAboutApp;
|
||||
private AppCompatDelegate mDelegate;
|
||||
|
@ -95,7 +93,6 @@ public class Preferences extends PreferenceActivity {
|
|||
getDelegate().installViewFactory();
|
||||
getDelegate().onCreate(savedInstanceState);
|
||||
super.onCreate(savedInstanceState);
|
||||
mDbHandler = new DbHandler(getBaseContext());
|
||||
addPreferencesFromResource(R.xml.preferences);
|
||||
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
|
@ -185,7 +182,8 @@ public class Preferences extends PreferenceActivity {
|
|||
String appName = getString(R.string.app_name);
|
||||
String downloadUrl = getString(R.string.url_app_download);
|
||||
|
||||
String recommendSubject = String.format(getString(R.string.recommend_subject),
|
||||
String recommendSubject =
|
||||
String.format(getString(R.string.recommend_subject),
|
||||
appName);
|
||||
String recommendText = String.format(getString(R.string.recommend_text),
|
||||
appName, downloadUrl);
|
||||
|
@ -211,7 +209,8 @@ public class Preferences extends PreferenceActivity {
|
|||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
String feedbackMail =(String) getText(R.string.mail_feedback);
|
||||
String feedback =(String) getText(R.string.prefs_feedback) + " - android v" + appVersion;
|
||||
String feedback =(String) getText(R.string.prefs_feedback) +
|
||||
" - android v" + appVersion;
|
||||
Intent intent = new Intent(Intent.ACTION_SENDTO);
|
||||
intent.setType("text/plain");
|
||||
intent.putExtra(Intent.EXTRA_SUBJECT, feedback);
|
||||
|
@ -347,7 +346,8 @@ public class Preferences extends PreferenceActivity {
|
|||
/* About App */
|
||||
pAboutApp = (Preference) findPreference("about_app");
|
||||
if (pAboutApp != null) {
|
||||
pAboutApp.setTitle(String.format(getString(R.string.about_android), getString(R.string.app_name)));
|
||||
pAboutApp.setTitle(String.format(getString(R.string.about_android),
|
||||
getString(R.string.app_name)));
|
||||
pAboutApp.setSummary(String.format(getString(R.string.about_version), appVersion));
|
||||
}
|
||||
|
||||
|
@ -530,8 +530,6 @@ public class Preferences extends PreferenceActivity {
|
|||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
mDbHandler.close();
|
||||
|
||||
super.onDestroy();
|
||||
getDelegate().onDestroy();
|
||||
}
|
||||
|
|
|
@ -82,20 +82,18 @@ public class UploadListActivity extends FileActivity implements UploadListFragme
|
|||
// but that's other story
|
||||
setFile(null);
|
||||
|
||||
// Navigation Drawer
|
||||
initDrawer();
|
||||
// setup toolbar
|
||||
setupToolbar();
|
||||
|
||||
// setup drawer
|
||||
setupDrawer();
|
||||
|
||||
// Add fragment with a transaction for setting a tag
|
||||
if(savedInstanceState == null) {
|
||||
createUploadListFragment();
|
||||
} // else, the Fragment Manager makes the job on configuration changes
|
||||
|
||||
// enable ActionBar app icon to behave as action to toggle nav drawer
|
||||
getSupportActionBar().setHomeButtonEnabled(true);
|
||||
mDrawerToggle.setDrawerIndicatorEnabled(true);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
getSupportActionBar().setTitle(R.string.uploads_view_title);
|
||||
|
||||
getSupportActionBar().setTitle(getString(R.string.uploads_view_title));
|
||||
}
|
||||
|
||||
private void createUploadListFragment(){
|
||||
|
@ -186,12 +184,11 @@ public class UploadListActivity extends FileActivity implements UploadListFragme
|
|||
(UploadListFragment) getSupportFragmentManager().findFragmentByTag(TAG_UPLOAD_LIST_FRAGMENT);
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
|
||||
mDrawerLayout.closeDrawer(GravityCompat.START);
|
||||
if (isDrawerOpen()) {
|
||||
closeDrawer();
|
||||
} else {
|
||||
mDrawerLayout.openDrawer(GravityCompat.START);
|
||||
openDrawer();
|
||||
}
|
||||
break;
|
||||
case R.id.action_retry_uploads:
|
||||
FileUploader.UploadRequester requester = new FileUploader.UploadRequester();
|
||||
requester.retryFailedUploads(this, null, null);
|
||||
|
@ -340,7 +337,6 @@ public class UploadListActivity extends FileActivity implements UploadListFragme
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultTitle() {
|
||||
return getString(R.string.uploads_view_title);
|
||||
}
|
||||
|
@ -352,9 +348,9 @@ public class UploadListActivity extends FileActivity implements UploadListFragme
|
|||
@Override
|
||||
protected void onAccountSet(boolean stateWasRecovered) {
|
||||
super.onAccountSet(stateWasRecovered);
|
||||
updateActionBarTitleAndHomeButton(null);
|
||||
getSupportActionBar().setTitle(getString(R.string.uploads_view_title));
|
||||
if (mAccountWasSet) {
|
||||
setUsernameInDrawer(findViewById(R.id.left_drawer), getAccount());
|
||||
setUsernameInDrawer(getAccount().name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue