Show gear for apps that provide general settings intent
Bug: 27276982 Change-Id: If598e2901a25f5df2b76a87a95590a5ff831a2dc
This commit is contained in:
@@ -35,10 +35,32 @@
|
|||||||
android:paddingBottom="10dip"
|
android:paddingBottom="10dip"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<!-- Application snippet label, version and icon -->
|
<LinearLayout
|
||||||
<include
|
android:layout_width="match_parent"
|
||||||
layout="@layout/app_item"
|
android:layout_height="wrap_content">
|
||||||
android:id="@+id/app_snippet" />
|
|
||||||
|
<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
|
<Space
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@@ -63,6 +63,7 @@ import android.view.Menu;
|
|||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
@@ -390,6 +391,28 @@ public class InstalledAppDetails extends AppInfoBase
|
|||||||
mForceStopButton.setText(R.string.force_stop);
|
mForceStopButton.setText(R.string.force_stop);
|
||||||
mUninstallButton = (Button) btnPanel.findViewById(R.id.left_button);
|
mUninstallButton = (Button) btnPanel.findViewById(R.id.left_button);
|
||||||
mForceStopButton.setEnabled(false);
|
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
|
@Override
|
||||||
|
Reference in New Issue
Block a user