rebase fixes

This commit is contained in:
Andy Scherzinger 2016-03-30 17:10:40 +02:00
parent 576b7b11dc
commit bf3deb49a2
6 changed files with 67 additions and 52 deletions

View file

@ -27,19 +27,16 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
<<<<<<< HEAD
android:background="@color/background_color">
=======
android:orientation="vertical"> android:orientation="vertical">
<include <include
layout="@layout/toolbar_standard"/> layout="@layout/toolbar_standard"/>
>>>>>>> layout fix due to added toolbar + oC license added
<FrameLayout <FrameLayout
android:id="@+id/upload_list_fragment" android:id="@+id/upload_list_fragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"/> android:layout_height="match_parent"
android:background="@color/background_color"/>
</LinearLayout> </LinearLayout>
<include <include

View file

@ -21,13 +21,10 @@ package com.owncloud.android.ui.activity;
import android.accounts.Account; import android.accounts.Account;
import android.accounts.AccountManager; import android.accounts.AccountManager;
import android.accounts.AccountManagerCallback;
import android.accounts.AccountManagerFuture; import android.accounts.AccountManagerFuture;
import android.accounts.OperationCanceledException;
import android.content.Intent; import android.content.Intent;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler;
import android.support.design.widget.NavigationView; import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat; import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout; import android.support.v4.widget.DrawerLayout;
@ -37,15 +34,12 @@ import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import com.owncloud.android.MainApp; import com.owncloud.android.MainApp;
import com.owncloud.android.R; import com.owncloud.android.R;
import com.owncloud.android.authentication.AccountUtils; import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.common.utils.Log_OC; 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.ui.TextDrawable;
import com.owncloud.android.utils.BitmapUtils; import com.owncloud.android.utils.BitmapUtils;
@ -114,14 +108,12 @@ public abstract class DrawerActivity extends ToolbarActivity {
if (mIsAccountChooserActive) { if (mIsAccountChooserActive) {
toggleAccountList(); toggleAccountList();
} }
updateActionBarTitleAndHomeButton(null);
invalidateOptionsMenu(); invalidateOptionsMenu();
} }
/** Called when a drawer has settled in a completely open state. */ /** Called when a drawer has settled in a completely open state. */
public void onDrawerOpened(View drawerView) { public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView); super.onDrawerOpened(drawerView);
getSupportActionBar().setTitle(R.string.app_name);
mDrawerToggle.setDrawerIndicatorEnabled(true); mDrawerToggle.setDrawerIndicatorEnabled(true);
invalidateOptionsMenu(); invalidateOptionsMenu();
} }
@ -129,7 +121,8 @@ public abstract class DrawerActivity extends ToolbarActivity {
// Set the drawer toggle as the DrawerListener // Set the drawer toggle as the DrawerListener
mDrawerLayout.setDrawerListener(mDrawerToggle); 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); menuItem.setChecked(true);
allFilesOption(); allFilesOption();
break; 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: case R.id.nav_settings:
Intent settingsIntent = new Intent(getApplicationContext(), Intent settingsIntent = new Intent(getApplicationContext(),
Preferences.class); Preferences.class);
@ -380,7 +379,6 @@ public abstract class DrawerActivity extends ToolbarActivity {
if (mDrawerToggle != null) { if (mDrawerToggle != null) {
mDrawerToggle.syncState(); mDrawerToggle.syncState();
if (isDrawerOpen()) { if (isDrawerOpen()) {
getSupportActionBar().setTitle(R.string.app_name);
mDrawerToggle.setDrawerIndicatorEnabled(true); mDrawerToggle.setDrawerIndicatorEnabled(true);
} }
} }

View file

@ -3,7 +3,7 @@
* *
* @author David A. Velasco * @author David A. Velasco
* Copyright (C) 2011 Bartek Przybylski * 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 * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2, * 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_WAITING_FOR_OP_ID = "WAITING_FOR_OP_ID";
private static final String KEY_ACTION_BAR_TITLE = "ACTION_BAR_TITLE"; 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; protected static final long DELAY_TO_REQUEST_OPERATIONS_LATER = 200;
/* Dialog tags */ /* 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. * @param result Result of the removal.
*/ */
@Override @Override
@ -291,14 +294,12 @@ public class FileActivity extends DrawerActivity
if (!result.isSuccess() && ( if (!result.isSuccess() && (
result.getCode() == ResultCode.UNAUTHORIZED || result.getCode() == ResultCode.UNAUTHORIZED ||
result.isIdPRedirection() ||
(result.isException() && result.getException() instanceof AuthenticatorException) (result.isException() && result.getException() instanceof AuthenticatorException)
)) { )) {
requestCredentialsUpdate(this); requestCredentialsUpdate(this);
if (result.getCode() == ResultCode.UNAUTHORIZED) { if (result.getCode() == ResultCode.UNAUTHORIZED) {
dismissLoadingDialog();
Toast t = Toast.makeText(this, ErrorMessageAdapter.getErrorCauseMessage(result, Toast t = Toast.makeText(this, ErrorMessageAdapter.getErrorCauseMessage(result,
operation, getResources()), operation, getResources()),
Toast.LENGTH_LONG); 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, * Invalidates the credentials stored for the current OC account and requests new credentials to the user,
* navigating to {@link AuthenticatorActivity} * navigating to {@link AuthenticatorActivity}
* *
* Equivalent to call requestCredentialsUpdate(context, null);
*
* @param context Android Context needed to access the {@link AccountManager}. Received as a parameter * @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. * to make the method accessible to {@link android.content.BroadcastReceiver}s.
*/ */
protected void requestCredentialsUpdate(Context context) { 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 { try {
/// step 1 - invalidate credentials of current account /// step 1 - invalidate credentials of current account
if (account == null) {
account = getAccount();
}
OwnCloudClient client; OwnCloudClient client;
OwnCloudAccount ocAccount = OwnCloudAccount ocAccount =
new OwnCloudAccount(getAccount(), context); new OwnCloudAccount(account, context);
client = (OwnCloudClientManagerFactory.getDefaultSingleton(). client = (OwnCloudClientManagerFactory.getDefaultSingleton().
removeClientFor(ocAccount)); removeClientFor(ocAccount));
if (client != null) { if (client != null) {
@ -364,23 +383,23 @@ public class FileActivity extends DrawerActivity
AccountManager am = AccountManager.get(context); AccountManager am = AccountManager.get(context);
if (cred.authTokenExpires()) { if (cred.authTokenExpires()) {
am.invalidateAuthToken( am.invalidateAuthToken(
getAccount().type, account.type,
cred.getAuthToken() cred.getAuthToken()
); );
} else { } else {
am.clearPassword(getAccount()); am.clearPassword(account);
} }
} }
} }
/// step 2 - request credentials to user /// step 2 - request credentials to user
Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class); Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class);
updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, getAccount()); updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, account);
updateAccountCredentials.putExtra( updateAccountCredentials.putExtra(
AuthenticatorActivity.EXTRA_ACTION, AuthenticatorActivity.EXTRA_ACTION,
AuthenticatorActivity.ACTION_UPDATE_EXPIRED_TOKEN); AuthenticatorActivity.ACTION_UPDATE_EXPIRED_TOKEN);
updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); 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) { } catch (com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException e) {
Toast.makeText(context, R.string.auth_account_does_not_exist, Toast.LENGTH_SHORT).show(); Toast.makeText(context, R.string.auth_account_does_not_exist, Toast.LENGTH_SHORT).show();
@ -516,6 +535,13 @@ public class FileActivity extends DrawerActivity
} }
@Override @Override
public void restart(){
Intent i = new Intent(this, FileDisplayActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
}
public void allFilesOption(){ public void allFilesOption(){
restart(); restart();
} }

View file

@ -515,7 +515,7 @@ public class FileDisplayActivity extends HookActivity
@Override @Override
public boolean onPrepareOptionsMenu(Menu menu) { 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_sort).setVisible(!drawerOpen);
menu.findItem(R.id.action_sync_account).setVisible(!drawerOpen); menu.findItem(R.id.action_sync_account).setVisible(!drawerOpen);
menu.findItem(R.id.action_switch_view).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: { case android.R.id.home: {
FileFragment second = getSecondFragment(); FileFragment second = getSecondFragment();
OCFile currentDir = getCurrentDir(); OCFile currentDir = getCurrentDir();
if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) { if (isDrawerOpen()) {
mDrawerLayout.closeDrawer(GravityCompat.START); closeDrawer();
} else if ((currentDir != null && currentDir.getParentId() != 0) || } else if ((currentDir != null && currentDir.getParentId() != 0) ||
(second != null && second.getFile() != null)) { (second != null && second.getFile() != null)) {
onBackPressed(); onBackPressed();
} else { } else {
mDrawerLayout.openDrawer(GravityCompat.START); openDrawer();
} }
break; break;
} }

View file

@ -4,7 +4,7 @@
* @author Bartek Przybylski * @author Bartek Przybylski
* @author David A. Velasco * @author David A. Velasco
* Copyright (C) 2011 Bartek Przybylski * 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 * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2, * 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.R;
import com.owncloud.android.authentication.AccountUtils; import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.datamodel.OCFile; 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.lib.common.utils.Log_OC;
import com.owncloud.android.utils.DisplayUtils; 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_REQUEST_PASSCODE = 5;
private static final int ACTION_CONFIRM_PASSCODE = 6; private static final int ACTION_CONFIRM_PASSCODE = 6;
private DbHandler mDbHandler;
private CheckBoxPreference pCode; private CheckBoxPreference pCode;
private Preference pAboutApp; private Preference pAboutApp;
private AppCompatDelegate mDelegate; private AppCompatDelegate mDelegate;
@ -95,7 +93,6 @@ public class Preferences extends PreferenceActivity {
getDelegate().installViewFactory(); getDelegate().installViewFactory();
getDelegate().onCreate(savedInstanceState); getDelegate().onCreate(savedInstanceState);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
mDbHandler = new DbHandler(getBaseContext());
addPreferencesFromResource(R.xml.preferences); addPreferencesFromResource(R.xml.preferences);
ActionBar actionBar = getSupportActionBar(); ActionBar actionBar = getSupportActionBar();
@ -185,7 +182,8 @@ public class Preferences extends PreferenceActivity {
String appName = getString(R.string.app_name); String appName = getString(R.string.app_name);
String downloadUrl = getString(R.string.url_app_download); 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); appName);
String recommendText = String.format(getString(R.string.recommend_text), String recommendText = String.format(getString(R.string.recommend_text),
appName, downloadUrl); appName, downloadUrl);
@ -211,7 +209,8 @@ public class Preferences extends PreferenceActivity {
@Override @Override
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
String feedbackMail =(String) getText(R.string.mail_feedback); 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 intent = new Intent(Intent.ACTION_SENDTO);
intent.setType("text/plain"); intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, feedback); intent.putExtra(Intent.EXTRA_SUBJECT, feedback);
@ -347,7 +346,8 @@ public class Preferences extends PreferenceActivity {
/* About App */ /* About App */
pAboutApp = (Preference) findPreference("about_app"); pAboutApp = (Preference) findPreference("about_app");
if (pAboutApp != null) { 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)); pAboutApp.setSummary(String.format(getString(R.string.about_version), appVersion));
} }
@ -530,8 +530,6 @@ public class Preferences extends PreferenceActivity {
@Override @Override
protected void onDestroy() { protected void onDestroy() {
mDbHandler.close();
super.onDestroy(); super.onDestroy();
getDelegate().onDestroy(); getDelegate().onDestroy();
} }

View file

@ -82,20 +82,18 @@ public class UploadListActivity extends FileActivity implements UploadListFragme
// but that's other story // but that's other story
setFile(null); setFile(null);
// Navigation Drawer // setup toolbar
initDrawer(); setupToolbar();
// setup drawer
setupDrawer();
// Add fragment with a transaction for setting a tag // Add fragment with a transaction for setting a tag
if(savedInstanceState == null) { if(savedInstanceState == null) {
createUploadListFragment(); createUploadListFragment();
} // else, the Fragment Manager makes the job on configuration changes } // else, the Fragment Manager makes the job on configuration changes
// enable ActionBar app icon to behave as action to toggle nav drawer getSupportActionBar().setTitle(getString(R.string.uploads_view_title));
getSupportActionBar().setHomeButtonEnabled(true);
mDrawerToggle.setDrawerIndicatorEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(R.string.uploads_view_title);
} }
private void createUploadListFragment(){ private void createUploadListFragment(){
@ -186,12 +184,11 @@ public class UploadListActivity extends FileActivity implements UploadListFragme
(UploadListFragment) getSupportFragmentManager().findFragmentByTag(TAG_UPLOAD_LIST_FRAGMENT); (UploadListFragment) getSupportFragmentManager().findFragmentByTag(TAG_UPLOAD_LIST_FRAGMENT);
switch (item.getItemId()) { switch (item.getItemId()) {
case android.R.id.home: case android.R.id.home:
if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) { if (isDrawerOpen()) {
mDrawerLayout.closeDrawer(GravityCompat.START); closeDrawer();
} else { } else {
mDrawerLayout.openDrawer(GravityCompat.START); openDrawer();
} }
break;
case R.id.action_retry_uploads: case R.id.action_retry_uploads:
FileUploader.UploadRequester requester = new FileUploader.UploadRequester(); FileUploader.UploadRequester requester = new FileUploader.UploadRequester();
requester.retryFailedUploads(this, null, null); requester.retryFailedUploads(this, null, null);
@ -340,7 +337,6 @@ public class UploadListActivity extends FileActivity implements UploadListFragme
} }
} }
@Override
protected String getDefaultTitle() { protected String getDefaultTitle() {
return getString(R.string.uploads_view_title); return getString(R.string.uploads_view_title);
} }
@ -352,9 +348,9 @@ public class UploadListActivity extends FileActivity implements UploadListFragme
@Override @Override
protected void onAccountSet(boolean stateWasRecovered) { protected void onAccountSet(boolean stateWasRecovered) {
super.onAccountSet(stateWasRecovered); super.onAccountSet(stateWasRecovered);
updateActionBarTitleAndHomeButton(null); getSupportActionBar().setTitle(getString(R.string.uploads_view_title));
if (mAccountWasSet) { if (mAccountWasSet) {
setUsernameInDrawer(findViewById(R.id.left_drawer), getAccount()); setUsernameInDrawer(getAccount().name);
} }
} }