Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 32869a46 authored by Diksha Gohlyan's avatar Diksha Gohlyan Committed by Automerger Merge Worker
Browse files

Merge "Breadcrumb arrow for rtl Language" into rvc-dev am: c68c9a1f

Change-Id: Iadb5a090f19775066a21e314aa4fa8fe37076dee
parents 3486e223 c68c9a1f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:autoMirrored="true"
        android:viewportWidth="24"
        android:viewportHeight="24">
    <path
+0 −8
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
        android:fromDegrees="90"
        android:toDegrees="90"
        android:pivotX="50%"
        android:pivotY="50%"
        android:drawable="@drawable/ic_breadcrumb_arrow">
</rotate>
 No newline at end of file

res/layout/item_subdir.xml

deleted100644 → 0
+0 −38
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 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.
-->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="?android:attr/listPreferredItemHeightSmall"
    android:paddingStart="?android:attr/listPreferredItemPaddingStart"
    android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
    android:gravity="center_vertical"
    android:orientation="horizontal"
    android:baselineAligned="false">

    <TextView
        android:id="@android:id/title"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:singleLine="true"
        android:ellipsize="end"
        android:textAlignment="viewStart"
        android:textAppearance="?android:attr/textAppearanceListItem"
        android:textColor="?android:attr/textColorPrimary" />

</LinearLayout>

res/layout/item_subdir_title.xml

deleted100644 → 0
+0 −35
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 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.
-->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:paddingEnd="8dp"
    android:orientation="horizontal"
    android:baselineAligned="false">

    <TextView
        android:id="@android:id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:singleLine="true"
        android:ellipsize="end"
        android:textAlignment="viewStart"
        android:drawablePadding="12dp"
        android:drawableRight="@drawable/ic_breadcrumb_arrow_down"
        android:textAppearance="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title"
        android:gravity="center_vertical"/>
</LinearLayout>
+0 −168
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 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.
 */

package com.android.documentsui;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Spinner;
import android.widget.TextView;

import com.android.documentsui.NavigationViewManager.Breadcrumb;
import com.android.documentsui.NavigationViewManager.Environment;
import com.android.documentsui.base.DocumentInfo;
import com.android.documentsui.base.RootInfo;
import com.android.documentsui.base.State;

import java.util.function.IntConsumer;

/**
 * Dropdown implementation of breadcrumb used for phone device layouts
 */

public final class DropdownBreadcrumb extends Spinner implements Breadcrumb {

    private DropdownAdapter mAdapter;

    public DropdownBreadcrumb(
            Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    public DropdownBreadcrumb(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public DropdownBreadcrumb(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public DropdownBreadcrumb(Context context) {
        super(context);
    }

    @Override
    public void setup(Environment env, State state, IntConsumer listener) {
        mAdapter = new DropdownAdapter(state, env);
        setOnItemSelectedListener(
                new OnItemSelectedListener() {
                    @Override
                    public void onItemSelected(
                            AdapterView<?> parent, View view, int position, long id) {
                        listener.accept(position);
                    }

                    @Override
                    public void onNothingSelected(AdapterView<?> parent) {}
                });
        setAccessibilityDelegate(new AccessibilityDelegate() {
            @Override
            public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
                if (event.getEventType() != AccessibilityEvent.TYPE_VIEW_SELECTED) {
                    super.onInitializeAccessibilityEvent(host, event);
                }
            }
        });
    }

    @Override
    public void show(boolean visibility) {
        if (visibility) {
            setVisibility(VISIBLE);
            setAdapter(mAdapter);
        } else {
            setVisibility(GONE);
            setAdapter(null);
        }
    }

    @Override
    public void postUpdate() {
        setSelection(mAdapter.getCount() - 1, false);
    }

    private static final class DropdownAdapter extends BaseAdapter {
        private Environment mEnv;
        private State mState;

        public DropdownAdapter(State state, Environment env) {
            mState = state;
            mEnv = env;
        }

        @Override
        public int getCount() {
            return mState.stack.size();
        }

        @Override
        public DocumentInfo getItem(int position) {
            return mState.stack.get(position);
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            if (convertView == null) {
                convertView = LayoutInflater.from(parent.getContext())
                        .inflate(R.layout.item_subdir_title, parent, false);
            }

            final TextView title = (TextView) convertView.findViewById(android.R.id.title);
            final DocumentInfo doc = getItem(position);

            if (position == 0) {
                final RootInfo root = mEnv.getCurrentRoot();
                title.setText(root.title);
            } else {
                title.setText(doc.displayName);
            }

            return convertView;
        }

        @Override
        public View getDropDownView(int position, View convertView, ViewGroup parent) {
            if (convertView == null) {
                convertView = LayoutInflater.from(parent.getContext())
                        .inflate(R.layout.item_subdir, parent, false);
            }

            final TextView title = (TextView) convertView.findViewById(android.R.id.title);
            final DocumentInfo doc = getItem(position);

            if (position == 0) {
                final RootInfo root = mEnv.getCurrentRoot();
                title.setText(root.title);
            } else {
                title.setText(doc.displayName);
            }

            return convertView;
        }
    }

}