logout button in drawer

This commit is contained in:
tobiasKaminsky 2017-04-26 16:57:03 +02:00 committed by AndyScherzinger
parent 7e5d7f1f4e
commit de9aa39c87
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B
12 changed files with 100 additions and 6 deletions

View File

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
fill="#000000"
height="24"
viewBox="0 0 24 24"
width="24"
id="svg2"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="ic_exit_to_app_black_24px.svg"
inkscape:export-xdpi="360"
inkscape:export-ydpi="360">
<metadata
id="metadata12">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs10" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1600"
inkscape:window-height="871"
id="namedview8"
showgrid="false"
inkscape:zoom="13.906433"
inkscape:cx="16.55722"
inkscape:cy="14.502003"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg2" />
<path
d="M0 0h24v24H0z"
fill="none"
id="path4" />
<path
d="M10.09 15.59L11.5 17l5-5-5-5-1.41 1.41L12.67 11H3v2h9.67l-2.58 2.59zM19 3H5c-1.11 0-2 .9-2 2v4h2V5h14v14H5v-4H3v4c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"
id="path6"
style="fill:#4b4b4b;fill-opacity:1" />
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -353,6 +353,10 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
navigationView.getMenu().removeItem(R.id.nav_contacts);
}
if (!getResources().getBoolean(R.bool.logout)) {
navigationView.getMenu().removeItem(R.id.nav_logout);
}
if (AccountUtils.hasSearchSupport(account)) {
if (!getResources().getBoolean(R.bool.recently_added_enabled)) {
navigationView.getMenu().removeItem(R.id.nav_recently_added);
@ -455,6 +459,11 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
ParticipateActivity.class);
startActivity(participateIntent);
break;
case R.id.nav_logout:
mCheckedMenuItem = -1;
menuItem.setChecked(false);
UserInfoActivity.openAccountRemovalConfirmationDialog(getAccount(), getFragmentManager(), true);
break;
case R.id.drawer_menu_account_add:
createAccount(false);
break;

View File

@ -24,9 +24,11 @@
package com.owncloud.android.ui.activity;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.app.FragmentManager;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
@ -70,6 +72,7 @@ public class UserInfoActivity extends FileActivity {
private static final String KEY_USER_DATA = "USER_DATA";
private static final String KEY_ACCOUNT = "ACCOUNT";
private static final String KEY_DIRECT_REMOVE = "DIRECT_REMOVE";
private static final int KEY_DELETE_CODE = 101;
@ -208,7 +211,7 @@ public class UserInfoActivity extends FileActivity {
changeAccountPassword(account);
break;
case R.id.delete_account:
openAccountRemovalConfirmationDialog(account);
openAccountRemovalConfirmationDialog(account, getFragmentManager(), false);
break;
default:
retval = super.onOptionsItemSelected(item);
@ -292,19 +295,22 @@ public class UserInfoActivity extends FileActivity {
startActivity(updateAccountCredentials);
}
private void openAccountRemovalConfirmationDialog(Account account) {
public static void openAccountRemovalConfirmationDialog(Account account, FragmentManager fragmentManager,
boolean removeDirectly) {
UserInfoActivity.AccountRemovalConfirmationDialog dialog =
UserInfoActivity.AccountRemovalConfirmationDialog.newInstance(account);
dialog.show(getFragmentManager(), "dialog");
UserInfoActivity.AccountRemovalConfirmationDialog.newInstance(account, removeDirectly);
dialog.show(fragmentManager, "dialog");
}
public static class AccountRemovalConfirmationDialog extends DialogFragment {
private Account account;
public static UserInfoActivity.AccountRemovalConfirmationDialog newInstance(Account account) {
public static UserInfoActivity.AccountRemovalConfirmationDialog newInstance(Account account,
boolean removeDirectly) {
Bundle bundle = new Bundle();
bundle.putParcelable(KEY_ACCOUNT, account);
bundle.putBoolean(KEY_DIRECT_REMOVE, removeDirectly);
UserInfoActivity.AccountRemovalConfirmationDialog dialog = new
UserInfoActivity.AccountRemovalConfirmationDialog();
@ -322,6 +328,7 @@ public class UserInfoActivity extends FileActivity {
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final boolean removeDirectly = getArguments().getBoolean(KEY_DIRECT_REMOVE);
return new AlertDialog.Builder(getActivity(), R.style.Theme_ownCloud_Dialog)
.setTitle(R.string.delete_account)
.setMessage(getResources().getString(R.string.delete_account_warning, account.name))
@ -334,9 +341,19 @@ public class UserInfoActivity extends FileActivity {
bundle.putParcelable(KEY_ACCOUNT, Parcels.wrap(account));
Intent intent = new Intent();
intent.putExtras(bundle);
if (getActivity() != null) {
if (getActivity() != null && !removeDirectly) {
getActivity().setResult(KEY_DELETE_CODE, intent);
getActivity().finish();
} else {
AccountManager am = (AccountManager) getActivity()
.getSystemService(ACCOUNT_SERVICE);
am.removeAccount(account, null, null);
Intent start = new Intent(getActivity(), FileDisplayActivity.class);
start.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(start);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 701 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 437 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 674 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 922 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -137,6 +137,11 @@
android:icon="@drawable/ic_participate"
android:orderInCategory="4"
android:title="@string/drawer_participate"/>
<item
android:id="@+id/nav_logout"
android:icon="@drawable/logout"
android:orderInCategory="4"
android:title="@string/drawer_logout"/>
</group>
<!--

View File

@ -38,6 +38,7 @@
<bool name = "share_with_users_feature">true</bool>
<bool name="show_whats_new">true</bool>
<bool name="show_external_links">true</bool>
<bool name="logout">false</bool>
// Contacts backup
<bool name="contacts_backup">true</bool>

View File

@ -654,6 +654,7 @@
<!-- Notifications -->
<string name="new_notification_received">New notification received</string>
<string name="drawer_logout">Logout</string>
</resources>

View File

@ -34,6 +34,7 @@
<bool name = "share_via_link_feature">true</bool>
<bool name = "share_with_users_feature">true</bool>
<bool name="show_external_links">true</bool>
<bool name="logout">true</bool>
<bool name="show_whats_new">true</bool>
<!-- To fill if you want to show webviews instead of regular welcome views -->