disable Install/Run/Uninstall button when the install process is running
To make things less confusing, this disables the main button on AppDetails when something is running. During install, it also changes the text of the button to "Installing..."
This commit is contained in:
parent
7d48ad736c
commit
5582e906c8
@ -326,6 +326,7 @@ public class AppDetails extends ActionBarActivity implements ProgressListener, A
|
|||||||
|
|
||||||
private final Context mctx = this;
|
private final Context mctx = this;
|
||||||
private Installer installer;
|
private Installer installer;
|
||||||
|
private static Button mainButton;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores relevant data that we want to keep track of when destroying the activity
|
* Stores relevant data that we want to keep track of when destroying the activity
|
||||||
@ -987,6 +988,8 @@ public class AppDetails extends ActionBarActivity implements ProgressListener, A
|
|||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "Tried to cancel, but the downloadHandler doesn't exist.");
|
Log.e(TAG, "Tried to cancel, but the downloadHandler doesn't exist.");
|
||||||
}
|
}
|
||||||
|
if (mainButton != null)
|
||||||
|
mainButton.setEnabled(true);
|
||||||
progressDialog = null;
|
progressDialog = null;
|
||||||
Toast.makeText(AppDetails.this, getString(R.string.download_cancelled), Toast.LENGTH_LONG).show();
|
Toast.makeText(AppDetails.this, getString(R.string.download_cancelled), Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
@ -1487,6 +1490,7 @@ public class AppDetails extends ActionBarActivity implements ProgressListener, A
|
|||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.app_details_header, container, false);
|
View view = inflater.inflate(R.layout.app_details_header, container, false);
|
||||||
|
mainButton = (Button) view.findViewById(R.id.btn_main);
|
||||||
setupView(view);
|
setupView(view);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
@ -1523,8 +1527,8 @@ public class AppDetails extends ActionBarActivity implements ProgressListener, A
|
|||||||
|
|
||||||
public void updateViews(View view) {
|
public void updateViews(View view) {
|
||||||
TextView statusView = (TextView) view.findViewById(R.id.status);
|
TextView statusView = (TextView) view.findViewById(R.id.status);
|
||||||
Button btMain = (Button) view.findViewById(R.id.btn_main);
|
mainButton.setVisibility(View.VISIBLE);
|
||||||
btMain.setVisibility(View.VISIBLE);
|
mainButton.setEnabled(true);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Check count > 0 due to incompatible apps resulting in an empty list.
|
Check count > 0 due to incompatible apps resulting in an empty list.
|
||||||
@ -1535,8 +1539,8 @@ public class AppDetails extends ActionBarActivity implements ProgressListener, A
|
|||||||
statusView.setText(getString(R.string.details_notinstalled));
|
statusView.setText(getString(R.string.details_notinstalled));
|
||||||
NfcHelper.disableAndroidBeam(getActivity());
|
NfcHelper.disableAndroidBeam(getActivity());
|
||||||
// Set Install button and hide second button
|
// Set Install button and hide second button
|
||||||
btMain.setText(R.string.menu_install);
|
mainButton.setText(R.string.menu_install);
|
||||||
btMain.setOnClickListener(mOnClickListener);
|
mainButton.setOnClickListener(mOnClickListener);
|
||||||
}
|
}
|
||||||
// If App is installed
|
// If App is installed
|
||||||
else if (getApp().isInstalled()) {
|
else if (getApp().isInstalled()) {
|
||||||
@ -1545,24 +1549,24 @@ public class AppDetails extends ActionBarActivity implements ProgressListener, A
|
|||||||
NfcHelper.setAndroidBeam(getActivity(), getApp().id);
|
NfcHelper.setAndroidBeam(getActivity(), getApp().id);
|
||||||
if (getApp().canAndWantToUpdate()) {
|
if (getApp().canAndWantToUpdate()) {
|
||||||
updateWanted = true;
|
updateWanted = true;
|
||||||
btMain.setText(R.string.menu_upgrade);
|
mainButton.setText(R.string.menu_upgrade);
|
||||||
}else {
|
}else {
|
||||||
updateWanted = false;
|
updateWanted = false;
|
||||||
if (((AppDetails)getActivity()).mPm.getLaunchIntentForPackage(getApp().id) != null){
|
if (((AppDetails)getActivity()).mPm.getLaunchIntentForPackage(getApp().id) != null){
|
||||||
btMain.setText(R.string.menu_launch);
|
mainButton.setText(R.string.menu_launch);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
btMain.setText(R.string.menu_uninstall);
|
mainButton.setText(R.string.menu_uninstall);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
btMain.setOnClickListener(mOnClickListener);
|
mainButton.setOnClickListener(mOnClickListener);
|
||||||
}
|
}
|
||||||
TextView currentVersion = (TextView) view.findViewById(R.id.current_version);
|
TextView currentVersion = (TextView) view.findViewById(R.id.current_version);
|
||||||
if (!getApks().isEmpty()) {
|
if (!getApks().isEmpty()) {
|
||||||
currentVersion.setText(getApks().getItem(0).version);
|
currentVersion.setText(getApks().getItem(0).version);
|
||||||
}else {
|
}else {
|
||||||
currentVersion.setVisibility(View.GONE);
|
currentVersion.setVisibility(View.GONE);
|
||||||
btMain.setVisibility(View.GONE);
|
mainButton.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1589,6 +1593,8 @@ public class AppDetails extends ActionBarActivity implements ProgressListener, A
|
|||||||
|
|
||||||
// If not installed, install
|
// If not installed, install
|
||||||
else if (getApp().suggestedVercode > 0) {
|
else if (getApp().suggestedVercode > 0) {
|
||||||
|
mainButton.setEnabled(false);
|
||||||
|
mainButton.setText(R.string.system_install_installing);
|
||||||
final Apk apkToInstall = ApkProvider.Helper.find(getActivity(), getApp().id, getApp().suggestedVercode);
|
final Apk apkToInstall = ApkProvider.Helper.find(getActivity(), getApp().id, getApp().suggestedVercode);
|
||||||
((AppDetails)getActivity()).install(apkToInstall);
|
((AppDetails)getActivity()).install(apkToInstall);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user