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

Commit 0c55bb10 authored by Jason Monk's avatar Jason Monk
Browse files

Show gear for apps that provide general settings intent

Bug: 27276982
Change-Id: If598e2901a25f5df2b76a87a95590a5ff831a2dc
parent 8d41c204
Loading
Loading
Loading
Loading
+26 −4
Original line number Diff line number Diff line
@@ -35,10 +35,32 @@
        android:paddingBottom="10dip"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <FrameLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1">
                <!-- Application snippet label, version and icon -->
                <include
                    layout="@layout/app_item"
                    android:id="@+id/app_snippet" />
            </FrameLayout>

            <ImageView
                android:id="@+id/gear"
                android:layout_width="48dp"
                android:layout_height="48dp"
                android:layout_gravity="center_vertical"
                android:padding="12dp"
                android:src="@drawable/ic_settings_24dp"
                android:tint="?android:attr/colorAccent"
                android:clickable="true"
                android:background="?android:attr/selectableItemBackground" />

        </LinearLayout>

        <Space
            android:layout_width="match_parent"
+23 −0
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
@@ -390,6 +391,28 @@ public class InstalledAppDetails extends AppInfoBase
        mForceStopButton.setText(R.string.force_stop);
        mUninstallButton = (Button) btnPanel.findViewById(R.id.left_button);
        mForceStopButton.setEnabled(false);

        View gear = mHeader.findViewById(R.id.gear);
        Intent i = new Intent(Intent.ACTION_APPLICATION_PREFERENCES);
        i.setPackage(mPackageName);
        final Intent intent = resolveIntent(i);
        if (intent != null) {
            gear.setVisibility(View.VISIBLE);
            gear.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    startActivity(intent);
                }
            });
        } else {
            gear.setVisibility(View.GONE);
        }
    }

    private Intent resolveIntent(Intent i) {
        ResolveInfo result = getContext().getPackageManager().resolveActivity(i, 0);
        return result != null ? new Intent(Intent.ACTION_APPLICATION_PREFERENCES)
                .setClassName(result.activityInfo.packageName, result.activityInfo.name) : null;
    }

    @Override