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

Commit 3cc4e9da authored by Vinod Krishnan's avatar Vinod Krishnan
Browse files

Show No permissions, if there are no permissions

Change-Id: I285e326994268fc5b561e4a445ac2af326a64397
parent 6317f684
Loading
Loading
Loading
Loading
+30 −11
Original line number Diff line number Diff line
@@ -14,6 +14,10 @@
     limitations under the License.
-->
<merge xmlns:android="http://schemas.android.com/apk/res/android">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
        <TextView
            android:id="@+id/header"
            android:layout_width="match_parent"
@@ -28,6 +32,21 @@
            android:fontFamily="sans-serif-condensed-light"
        />

        <TextView
            android:id="@+id/details"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:minHeight="@dimen/settings_header_base_height"
            android:layout_marginLeft="16dp"
            android:layout_marginTop="@dimen/settings_header_top_margin"
            android:maxLines="2"
            android:ellipsize="end"
            android:textColor="@color/permissions_settings_item_color"
            android:textSize="14sp"
            android:visibility="gone"
        />
    </LinearLayout>

    <android.support.wearable.view.WearableListView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/wheel"
+9 −9
Original line number Diff line number Diff line
@@ -123,16 +123,16 @@ public final class AppPermissionsFragmentWear extends TitledSettingsFragment {
        super.onViewCreated(view, savedInstanceState);
        if (mAppPermissions != null) {
            initializeLayout(mAdapter);
            bindHeader(mAppPermissions.getPackageInfo());
            mHeader.setText(R.string.app_permissions);
            mDetails.setText(R.string.no_permissions);
            if (mAdapter.getItemCount() == 0) {
                mDetails.setVisibility(View.VISIBLE);
                mWheel.setVisibility(View.GONE);
            } else {
                mDetails.setVisibility(View.GONE);
                mWheel.setVisibility(View.VISIBLE);
            }
        }

    private void bindHeader(PackageInfo packageInfo) {
        Activity activity = getActivity();
        PackageManager pm = activity.getPackageManager();
        ApplicationInfo appInfo = packageInfo.applicationInfo;
        CharSequence label = appInfo.loadLabel(pm);
        mHeader.setText(label);
    }

    private void initializePermissionGroupList() {
+15 −6
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.android.packageinstaller.permission.ui.wear.settings.ViewUtils;
@@ -46,6 +46,7 @@ public abstract class TitledSettingsFragment extends Fragment implements
    private int mInitialHeaderHeight;

    protected TextView mHeader;
    protected TextView mDetails;
    protected WearableListView mWheel;

    private int mCharLimitShortTitle;
@@ -114,6 +115,9 @@ public abstract class TitledSettingsFragment extends Fragment implements
        mHeader.addOnLayoutChangeListener(this);
        mHeader.addTextChangedListener(mHeaderTextWatcher);

        mDetails = (TextView) v.findViewById(R.id.details);
        mDetails.addOnLayoutChangeListener(this);

        mWheel.setAdapter(adapter);
        mWheel.addOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
@@ -134,13 +138,14 @@ public abstract class TitledSettingsFragment extends Fragment implements

        adjustHeaderSize();

        positionOnCircular(getContext(), mHeader, mWheel);
        positionOnCircular(getContext(), mHeader, mDetails, mWheel);
    }

    public void positionOnCircular(Context context, View header, final ViewGroup wheel) {
    public void positionOnCircular(Context context, View header, View details,
            final ViewGroup wheel) {
        if (ViewUtils.getIsCircular(context)) {
            FrameLayout.LayoutParams params =
                    (FrameLayout.LayoutParams) header.getLayoutParams();
            LinearLayout.LayoutParams params =
                    (LinearLayout.LayoutParams) header.getLayoutParams();
            params.topMargin = (int) context.getResources().getDimension(
                    R.dimen.settings_header_top_margin_circular);
            // Note that the margins are made symmetrical here. Since they're symmetrical we choose
@@ -152,10 +157,14 @@ public abstract class TitledSettingsFragment extends Fragment implements
            params.rightMargin = margin;
            params.gravity = Gravity.CENTER_HORIZONTAL;
            header.setLayoutParams(params);
            details.setLayoutParams(params);

            if (header instanceof TextView) {
                ((TextView) header).setGravity(Gravity.CENTER);
            }
            if (details instanceof TextView) {
                ((TextView) details).setGravity(Gravity.CENTER);
            }

            final int leftPadding = (int) context.getResources().getDimension(
                    R.dimen.round_content_padding_left);
@@ -209,7 +218,7 @@ public abstract class TitledSettingsFragment extends Fragment implements
        }
        mHeader.setMinHeight((int) height);

        FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mHeader.getLayoutParams();
        LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) mHeader.getLayoutParams();
        final Context context = getContext();
        if (!singleLine) {
            // Make the top margin a little bit smaller so there is more space for the title.