diff --git a/res/values/strings.xml b/res/values/strings.xml
index 560c9b42e..143888446 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -240,5 +240,6 @@
Requesting root access…
Root access denied
Either your Android device is not rooted or you have denied root access for F-Droid.
+ Update all
diff --git a/src/org/fdroid/fdroid/installer/DefaultInstaller.java b/src/org/fdroid/fdroid/installer/DefaultInstaller.java
index ddb38caf7..9c1a9af91 100644
--- a/src/org/fdroid/fdroid/installer/DefaultInstaller.java
+++ b/src/org/fdroid/fdroid/installer/DefaultInstaller.java
@@ -117,4 +117,9 @@ public class DefaultInstaller extends Installer {
}
}
+ @Override
+ public boolean supportsUnattendedOperations() {
+ return false;
+ }
+
}
diff --git a/src/org/fdroid/fdroid/installer/Installer.java b/src/org/fdroid/fdroid/installer/Installer.java
index bc0cc549c..1a4917386 100644
--- a/src/org/fdroid/fdroid/installer/Installer.java
+++ b/src/org/fdroid/fdroid/installer/Installer.java
@@ -211,4 +211,6 @@ abstract public class Installer {
}
public abstract boolean handleOnActivityResult(int requestCode, int resultCode, Intent data);
+
+ public abstract boolean supportsUnattendedOperations();
}
diff --git a/src/org/fdroid/fdroid/installer/RootInstaller.java b/src/org/fdroid/fdroid/installer/RootInstaller.java
index 14697d76d..3c62d71a1 100644
--- a/src/org/fdroid/fdroid/installer/RootInstaller.java
+++ b/src/org/fdroid/fdroid/installer/RootInstaller.java
@@ -241,6 +241,11 @@ public class RootInstaller extends Installer {
});
}
+ @Override
+ public boolean supportsUnattendedOperations() {
+ return true;
+ }
+
/**
* pm install [-l] [-r] [-t] [-i INSTALLER_PACKAGE_NAME] [-s] [-f] [--algo
* --key --iv ] [--originating-uri
diff --git a/src/org/fdroid/fdroid/installer/SystemPermissionInstaller.java b/src/org/fdroid/fdroid/installer/SystemPermissionInstaller.java
index 51da59fa5..6ae0bb377 100644
--- a/src/org/fdroid/fdroid/installer/SystemPermissionInstaller.java
+++ b/src/org/fdroid/fdroid/installer/SystemPermissionInstaller.java
@@ -167,6 +167,11 @@ public class SystemPermissionInstaller extends Installer {
return false;
}
+ @Override
+ public boolean supportsUnattendedOperations() {
+ return false;
+ }
+
public final int INSTALL_REPLACE_EXISTING = 2;
/**
diff --git a/src/org/fdroid/fdroid/views/fragments/CanUpdateAppsFragment.java b/src/org/fdroid/fdroid/views/fragments/CanUpdateAppsFragment.java
index d42cbd6c2..9a7cb1c65 100644
--- a/src/org/fdroid/fdroid/views/fragments/CanUpdateAppsFragment.java
+++ b/src/org/fdroid/fdroid/views/fragments/CanUpdateAppsFragment.java
@@ -1,13 +1,39 @@
+
package org.fdroid.fdroid.views.fragments;
+import android.content.Context;
import android.net.Uri;
+import android.os.Bundle;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.FrameLayout;
+import android.widget.LinearLayout;
+import android.widget.ListView;
+import android.widget.ProgressBar;
+import android.widget.TextView;
+
import org.fdroid.fdroid.R;
import org.fdroid.fdroid.data.AppProvider;
+import org.fdroid.fdroid.installer.Installer;
import org.fdroid.fdroid.views.AppListAdapter;
import org.fdroid.fdroid.views.CanUpdateAppListAdapter;
public class CanUpdateAppsFragment extends AppListFragment {
+ // copied from ListFragment
+ static final int INTERNAL_EMPTY_ID = 0x00ff0001;
+ static final int INTERNAL_PROGRESS_CONTAINER_ID = 0x00ff0002;
+ static final int INTERNAL_LIST_CONTAINER_ID = 0x00ff0003;
+ // added for update button
+ static final int UPDATE_ALL_BUTTON_ID = 0x00ff0004;
+
+ private Button mUpdateAllButton;
+ private Installer mInstaller;
+
@Override
protected AppListAdapter getAppListAdapter() {
return new CanUpdateAppListAdapter(getActivity(), null);
@@ -23,4 +49,114 @@ public class CanUpdateAppsFragment extends AppListFragment {
return AppProvider.getCanUpdateUri();
}
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ mInstaller = Installer.getActivityInstaller(getActivity(), getActivity()
+ .getPackageManager(), null);
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+
+ mUpdateAllButton.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ // TODO
+
+ }
+ });
+ }
+
+ // TODO: not really called again after coming back from preference
+ @Override
+ public void onResume() {
+ super.onResume();
+
+ if (mInstaller.supportsUnattendedOperations()) {
+ mUpdateAllButton.setVisibility(View.VISIBLE);
+ } else {
+ mUpdateAllButton.setVisibility(View.GONE);
+ }
+ }
+
+ /**
+ * Copied from ListFragment and added EditText for search on top of list. We
+ * do not use a custom layout here, because this breaks the progress bar
+ * functionality of ListFragment.
+ *
+ * @param inflater
+ * @param container
+ * @param savedInstanceState
+ * @return
+ */
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ final Context context = getActivity();
+
+ FrameLayout root = new FrameLayout(context);
+
+ // ------------------------------------------------------------------
+
+ LinearLayout pframe = new LinearLayout(context);
+ pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
+ pframe.setOrientation(LinearLayout.VERTICAL);
+ pframe.setVisibility(View.GONE);
+ pframe.setGravity(Gravity.CENTER);
+
+ ProgressBar progress = new ProgressBar(context, null,
+ android.R.attr.progressBarStyleLarge);
+ pframe.addView(progress, new FrameLayout.LayoutParams(
+ ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
+
+ root.addView(pframe, new FrameLayout.LayoutParams(
+ ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
+
+ // ------------------------------------------------------------------
+
+ FrameLayout lframe = new FrameLayout(context);
+ lframe.setId(INTERNAL_LIST_CONTAINER_ID);
+
+ TextView tv = new TextView(getActivity());
+ tv.setId(INTERNAL_EMPTY_ID);
+ tv.setGravity(Gravity.CENTER);
+ lframe.addView(tv, new FrameLayout.LayoutParams(
+ ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
+
+ // Added update all button
+ LinearLayout linearLayout = new LinearLayout(context);
+ linearLayout.setOrientation(LinearLayout.VERTICAL);
+
+ mUpdateAllButton = new Button(context);
+ mUpdateAllButton.setId(UPDATE_ALL_BUTTON_ID);
+ mUpdateAllButton.setText(R.string.update_all);
+ mUpdateAllButton.setCompoundDrawablesWithIntrinsicBounds(
+ getResources().getDrawable(R.drawable.ic_menu_refresh), null, null, null);
+
+ linearLayout.addView(mUpdateAllButton, new FrameLayout.LayoutParams(
+ ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
+
+ ListView lv = new ListView(getActivity());
+ lv.setId(android.R.id.list);
+ lv.setDrawSelectorOnTop(false);
+ linearLayout.addView(lv, new FrameLayout.LayoutParams(
+ ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
+
+ lframe.addView(linearLayout, new FrameLayout.LayoutParams(
+ ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
+
+ root.addView(lframe, new FrameLayout.LayoutParams(
+ ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
+
+ // ------------------------------------------------------------------
+
+ root.setLayoutParams(new FrameLayout.LayoutParams(
+ ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
+
+ return root;
+ }
+
}