mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 09:39:25 +03:00
housekeeping removing old account switching code
This commit is contained in:
parent
0f8f714645
commit
7f72e8cabd
8 changed files with 44 additions and 390 deletions
|
@ -28,31 +28,4 @@
|
|||
app:headerLayout="@layout/drawer_header"
|
||||
app:menu="@menu/drawer_menu"/>
|
||||
|
||||
<!--TODO re-enable when "Accounts" is available in Navigation Drawer-->
|
||||
<!--<LinearLayout-->
|
||||
<!--android:layout_width="match_parent"-->
|
||||
<!--android:layout_height="wrap_content"-->
|
||||
<!--android:layout_margin="5dp">-->
|
||||
|
||||
<!--<ImageView-->
|
||||
<!--android:id="@+id/drawer_userIcon"-->
|
||||
<!--android:layout_width="40dp"-->
|
||||
<!--android:layout_height="40dp"-->
|
||||
<!--android:src="@drawable/abc_ab_bottom_solid_dark_holo" />-->
|
||||
|
||||
<!--<TextView-->
|
||||
<!--android:id="@+id/drawer_username"-->
|
||||
<!--android:layout_width="wrap_content"-->
|
||||
<!--android:layout_height="wrap_content"-->
|
||||
<!--android:layout_gravity="center_vertical"-->
|
||||
<!--android:layout_marginLeft="5dp"-->
|
||||
<!--android:layout_marginStart="5dp"-->
|
||||
<!--android:textAppearance="?android:attr/textAppearanceLarge" />-->
|
||||
|
||||
<!--</LinearLayout>-->
|
||||
|
||||
<!--<TextView-->
|
||||
<!--android:layout_width="fill_parent"-->
|
||||
<!--android:layout_height="2dip"-->
|
||||
<!--android:background="@color/list_item_lastmod_and_filesize_text" />-->
|
||||
</merge>
|
|
@ -1,22 +0,0 @@
|
|||
<!--
|
||||
Copyright 2013 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/drawer_radio_group"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:orientation="vertical" >
|
||||
</RadioGroup>
|
|
@ -1,52 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
ownCloud Android client application
|
||||
|
||||
Copyright (C) 2015 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,
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/itemLayout"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:orientation="horizontal"
|
||||
android:background="@color/background_color"
|
||||
android:layout_marginTop="@dimen/standard_margin"
|
||||
android:layout_marginBottom="@dimen/standard_margin"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/itemIcon"
|
||||
android:layout_width="24sp"
|
||||
android:layout_height="24sp"
|
||||
android:layout_marginLeft="@dimen/standard_margin"
|
||||
android:layout_gravity="center_vertical"
|
||||
/>
|
||||
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/itemTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="22dp"
|
||||
android:paddingRight="@dimen/standard_margin"
|
||||
android:textColor="@color/drawerMenuTextColor"
|
||||
android:text="@string/app_name"
|
||||
android:textStyle="normal"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textSize="14sp"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
ownCloud Android client application
|
||||
|
||||
Copyright (C) 2015 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,
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
<RadioButton xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/drawer_radiobutton"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="56dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="@dimen/standard_padding"
|
||||
android:paddingRight="@dimen/standard_padding"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="18dp" />
|
|
@ -1,3 +1,22 @@
|
|||
/**
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author Andy Scherzinger
|
||||
* 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,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.ui.activity;
|
||||
|
||||
import android.accounts.Account;
|
||||
|
|
|
@ -74,8 +74,7 @@ import com.owncloud.android.utils.ErrorMessageAdapter;
|
|||
|
||||
|
||||
/**
|
||||
* Activity with common behaviour for activities handling {@link OCFile}s in ownCloud
|
||||
* {@link Account}s .
|
||||
* Activity with common behaviour for activities handling {@link OCFile}s in ownCloud {@link Account}s .
|
||||
*/
|
||||
public class FileActivity extends DrawerActivity
|
||||
implements OnRemoteOperationListener, ComponentsGetter, SslUntrustedCertDialog.OnSslUntrustedCertListener {
|
||||
|
@ -122,9 +121,6 @@ public class FileActivity extends DrawerActivity
|
|||
protected FileUploaderBinder mUploaderBinder = null;
|
||||
private ServiceConnection mDownloadServiceConnection, mUploadServiceConnection = null;
|
||||
|
||||
// TODO re-enable when "Accounts" is available in Navigation Drawer
|
||||
// protected boolean mShowAccounts = false;
|
||||
|
||||
/**
|
||||
* Loads the ownCloud {@link Account} and main {@link OCFile} to be handled by the instance of
|
||||
* the {@link FileActivity}.
|
||||
|
@ -529,7 +525,6 @@ public class FileActivity extends DrawerActivity
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected(ComponentName component) {
|
||||
if (component.equals(new ComponentName(FileActivity.this, OperationsService.class))) {
|
||||
|
@ -540,23 +535,16 @@ public class FileActivity extends DrawerActivity
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public FileDownloaderBinder getFileDownloaderBinder() {
|
||||
return mDownloaderBinder;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public FileUploaderBinder getFileUploaderBinder() {
|
||||
return mUploaderBinder;
|
||||
}
|
||||
|
||||
// TODO re-enable when "Accounts" is available in Navigation Drawer
|
||||
// public void closeDrawer() {
|
||||
// mDrawerLayout.closeDrawers();
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void allFilesOption(){
|
||||
restart();
|
||||
|
@ -595,39 +583,5 @@ public class FileActivity extends DrawerActivity
|
|||
// nothing to do
|
||||
}
|
||||
|
||||
private class DrawerItemClickListener implements ListView.OnItemClickListener {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
// TODO re-enable when "Accounts" is available in Navigation Drawer
|
||||
// if (mShowAccounts && position > 0){
|
||||
// position = position - 1;
|
||||
// }
|
||||
switch (position){
|
||||
// TODO re-enable when "Accounts" is available in Navigation Drawer
|
||||
// case 0: // Accounts
|
||||
// mShowAccounts = !mShowAccounts;
|
||||
// mNavigationDrawerAdapter.setShowAccounts(mShowAccounts);
|
||||
// mNavigationDrawerAdapter.notifyDataSetChanged();
|
||||
// break;
|
||||
|
||||
case 0: // All Files
|
||||
allFilesOption();
|
||||
//mDrawerLayout.closeDrawers();
|
||||
break;
|
||||
|
||||
// TODO Enable when "On Device" is recovered ?
|
||||
// case 2:
|
||||
// MainApp.showOnlyFilesOnDevice(true);
|
||||
// mDrawerLayout.closeDrawers();
|
||||
// break;
|
||||
|
||||
case 1: // Settings
|
||||
Intent settingsIntent = new Intent(getApplicationContext(),
|
||||
Preferences.class);
|
||||
startActivity(settingsIntent);
|
||||
//mDrawerLayout.closeDrawers();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,22 @@
|
|||
/**
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author Andy Scherzinger
|
||||
* 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,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.owncloud.android.ui.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
@ -43,7 +62,7 @@ public class ToolbarActivity extends AppCompatActivity {
|
|||
String title = getString(R.string.default_display_name_for_root_folder); // default
|
||||
boolean inRoot;
|
||||
|
||||
// choose the appropiate title
|
||||
// choose the appropriate title
|
||||
inRoot = (
|
||||
chosenFile == null ||
|
||||
(chosenFile.isFolder() && chosenFile.getParentId() == FileDataStorageManager.ROOT_PARENT_ID)
|
||||
|
@ -52,11 +71,11 @@ public class ToolbarActivity extends AppCompatActivity {
|
|||
title = chosenFile.getFileName();
|
||||
}
|
||||
|
||||
/// set the chosen title
|
||||
// set the chosen title
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
actionBar.setTitle(title);
|
||||
|
||||
/// also as content description
|
||||
// also as content description
|
||||
View actionBarTitleView = getWindow().getDecorView().findViewById(
|
||||
getResources().getIdentifier("action_bar_title", "id", "android")
|
||||
);
|
||||
|
@ -65,7 +84,7 @@ public class ToolbarActivity extends AppCompatActivity {
|
|||
actionBarTitleView.setContentDescription(title);
|
||||
}
|
||||
|
||||
/// set home button properties
|
||||
// set home button properties
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
actionBar.setDisplayShowTitleEnabled(true);
|
||||
}
|
||||
|
|
|
@ -1,210 +0,0 @@
|
|||
/**
|
||||
* ownCloud Android client application
|
||||
*
|
||||
* @author tobiasKaminsky
|
||||
* @author masensio
|
||||
* Copyright (C) 2015 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,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.owncloud.android.ui.adapter;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.authentication.AccountUtils;
|
||||
import com.owncloud.android.ui.NavigationDrawerItem;
|
||||
import com.owncloud.android.ui.activity.FileActivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
// TODO remove complete class as soon as account switcher v2 is implemented, keep it until then for inspiration
|
||||
public class NavigationDrawerListAdapter extends BaseAdapter {
|
||||
|
||||
private final static String TAG = NavigationDrawerListAdapter.class.getSimpleName();
|
||||
|
||||
private Context mContext;
|
||||
|
||||
private ArrayList<NavigationDrawerItem> mNavigationDrawerItems;
|
||||
private ArrayList<Object> mAll = new ArrayList<Object>();
|
||||
private Account[] mAccounts;
|
||||
private boolean mShowAccounts;
|
||||
private Account mCurrentAccount;
|
||||
private FileActivity mFileActivity;
|
||||
|
||||
|
||||
public NavigationDrawerListAdapter(Context context, FileActivity fileActivity,
|
||||
ArrayList<NavigationDrawerItem> navigationDrawerItems){
|
||||
mFileActivity = fileActivity;
|
||||
mContext = context;
|
||||
mNavigationDrawerItems = navigationDrawerItems;
|
||||
|
||||
updateAccountList();
|
||||
|
||||
mAll.addAll(mNavigationDrawerItems);
|
||||
}
|
||||
|
||||
public void updateAccountList(){
|
||||
AccountManager am = (AccountManager) mContext.getSystemService(mContext.ACCOUNT_SERVICE);
|
||||
mAccounts = am.getAccountsByType(MainApp.getAccountType());
|
||||
mCurrentAccount = AccountUtils.getCurrentOwnCloudAccount(mContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
if (mShowAccounts){
|
||||
return mNavigationDrawerItems.size() + 1;
|
||||
} else {
|
||||
return mNavigationDrawerItems.size();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
//return all.get(position);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
|
||||
LayoutInflater inflator = (LayoutInflater) mContext
|
||||
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
|
||||
if (mAll.size() > position) {
|
||||
// Normal entry
|
||||
if (mAll.get(position) instanceof NavigationDrawerItem){
|
||||
NavigationDrawerItem navItem = (NavigationDrawerItem) mAll.get(position);
|
||||
|
||||
View view = inflator.inflate(R.layout.drawer_list_item, null);
|
||||
|
||||
LinearLayout itemLayout = (LinearLayout) view.findViewById(R.id.itemLayout);
|
||||
itemLayout.setContentDescription(navItem.getContentDescription());
|
||||
|
||||
TextView itemText = (TextView) view.findViewById(R.id.itemTitle);
|
||||
itemText.setText(navItem.getTitle());
|
||||
|
||||
if(navItem.getIcon()!=0) {
|
||||
ImageView itemImage = (ImageView) view.findViewById(R.id.itemIcon);
|
||||
itemImage.setImageResource(navItem.getIcon());
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
// TODO re-enable when "Accounts" is available in Navigation Drawer
|
||||
// Account
|
||||
// if (mAll.get(position) instanceof Account[]){
|
||||
// final View view = inflator.inflate(R.layout.drawer_account_group, null);
|
||||
//
|
||||
// final RadioGroup group = (RadioGroup) view.findViewById(R.id.drawer_radio_group);
|
||||
//
|
||||
// for (Account account : mAccounts) {
|
||||
// RadioButton rb = new RadioButton(mContext);
|
||||
//
|
||||
// rb.setText(account.name);
|
||||
// rb.setContentDescription(account.name);
|
||||
// rb.setTextColor(Color.BLACK);
|
||||
// rb.setEllipsize(TextUtils.TruncateAt.MIDDLE);
|
||||
// rb.setSingleLine();
|
||||
// rb.setCompoundDrawablePadding(30);
|
||||
//
|
||||
//
|
||||
// try {
|
||||
// // using adapted algorithm from /core/js/placeholder.js:50
|
||||
// int lastAtPos = account.name.lastIndexOf("@");
|
||||
// String username = account.name.substring(0, lastAtPos);
|
||||
// byte[] seed = username.getBytes("UTF-8");
|
||||
// MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
//// Integer seedMd5Int = Math.abs(new String(Hex.encodeHex(seedMd5))
|
||||
//// .hashCode());
|
||||
// Integer seedMd5Int = String.format(Locale.ROOT, "%032x",
|
||||
// new BigInteger(1, md.digest(seed))).hashCode();
|
||||
//
|
||||
// double maxRange = java.lang.Integer.MAX_VALUE;
|
||||
// float hue = (float) (seedMd5Int / maxRange * 360);
|
||||
//
|
||||
// int[] rgb = BitmapUtils.HSLtoRGB(hue, 90.0f, 65.0f, 1.0f);
|
||||
//
|
||||
// TextDrawable text = new TextDrawable(username.substring(0, 1).toUpperCase(),
|
||||
// rgb[0], rgb[1], rgb[2]);
|
||||
// rb.setCompoundDrawablesWithIntrinsicBounds(text, null, null, null);
|
||||
//
|
||||
//
|
||||
// } catch (Exception e){
|
||||
// Log_OC.d(TAG, e.toString());
|
||||
// rb.setTextColor(mContext.getResources().getColor(R.color.black));
|
||||
// }
|
||||
// RadioGroup.LayoutParams params = new RadioGroup.LayoutParams(
|
||||
// LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
|
||||
// params.weight=1.0f;
|
||||
// params.setMargins(15, 5, 5, 5);
|
||||
//
|
||||
// // Check the current account that is being used
|
||||
// if (account.name.equals(mCurrentAccount.name)) {
|
||||
// rb.setChecked(true);
|
||||
// } else {
|
||||
// rb.setChecked(false);
|
||||
// }
|
||||
//
|
||||
// group.addView(rb, params);
|
||||
// }
|
||||
//
|
||||
// group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener(){
|
||||
// public void onCheckedChanged(RadioGroup group, int checkedId) {
|
||||
// // checkedId is the RadioButton selected
|
||||
// RadioButton rb = (RadioButton) view.findViewById(checkedId);
|
||||
//
|
||||
// AccountUtils.setCurrentOwnCloudAccount(mContext,rb.getText().toString());
|
||||
// notifyDataSetChanged();
|
||||
// mFileActivity.closeDrawer();
|
||||
//
|
||||
// // restart the main activity
|
||||
// mFileActivity.restart();
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// return view;
|
||||
// }
|
||||
}
|
||||
return convertView;
|
||||
}
|
||||
|
||||
//TODO re-enable when "Accounts" is available in Navigation Drawer
|
||||
// TODO update Account List after creating a new account and on fresh installation
|
||||
// public void setShowAccounts(boolean value){
|
||||
// mAll.clear();
|
||||
// mAll.addAll(mNavigationDrawerItems);
|
||||
//
|
||||
// if (value){
|
||||
// mAll.add(1, mAccounts);
|
||||
// }
|
||||
// mShowAccounts = value;
|
||||
// }
|
||||
}
|
Loading…
Reference in a new issue