diff --git a/res/layout/repo_item.xml b/res/layout/repo_item.xml index 9cc61308b..58d983d18 100644 --- a/res/layout/repo_item.xml +++ b/res/layout/repo_item.xml @@ -27,12 +27,12 @@ android:layout_toRightOf="@id/img" android:layout_alignParentLeft="true"/> - <TextView android:id="@+id/repo_not_signed" + <TextView android:id="@+id/repo_unsigned" android:textSize="14sp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/repo_name" - android:textColor="@color/unsigned" - android:text="@string/unsigned" /> + android:text="@string/unsigned" + android:textColor="@color/unsigned"/> </RelativeLayout> diff --git a/res/layout/repodetails.xml b/res/layout/repodetails.xml index f888f1142..ad06cdc07 100644 --- a/res/layout/repodetails.xml +++ b/res/layout/repodetails.xml @@ -123,7 +123,7 @@ <Button android:id="@+id/btn_update" android:layout_centerHorizontal="true" - android:text="@string/update" + android:text="@string/repo_update" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@id/text_not_yet_updated"/> diff --git a/res/values/strings.xml b/res/values/strings.xml index 8d6722aa0..daabe25af 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -166,6 +166,7 @@ <string name="repo_signature">Signature</string> <string name="repo_description">Description</string> <string name="repo_last_update">Last update</string> + <string name="repo_update">Update</string> <string name="repo_name">Name</string> <string name="unsigned_description">This means that the list of applications could not be verified. You should be careful diff --git a/src/org/fdroid/fdroid/DB.java b/src/org/fdroid/fdroid/DB.java index 2046f944d..78391392f 100644 --- a/src/org/fdroid/fdroid/DB.java +++ b/src/org/fdroid/fdroid/DB.java @@ -535,6 +535,10 @@ public class DB { public boolean isSigned() { return this.pubkey != null && this.pubkey.length() > 0; } + + public boolean hasBeenUpdated() { + return this.lastetag != null; + } } private final int DBVersion = 31; diff --git a/src/org/fdroid/fdroid/ManageRepo.java b/src/org/fdroid/fdroid/ManageRepo.java index c362d2a92..5a688d482 100644 --- a/src/org/fdroid/fdroid/ManageRepo.java +++ b/src/org/fdroid/fdroid/ManageRepo.java @@ -65,6 +65,12 @@ public class ManageRepo extends ListActivity { private RepoAdapter repoAdapter; + /** + * True if activity started with an intent such as from QR code. False if + * opened from, e.g. the main menu. + */ + private boolean isImportingRepo = false; + @Override protected void onCreate(Bundle savedInstanceState) { @@ -108,6 +114,9 @@ public class ManageRepo extends ListActivity { String host = uri.getHost().toLowerCase(Locale.ENGLISH); if (scheme.equals("fdroidrepos") || scheme.equals("fdroidrepo") || scheme.equals("https") || scheme.equals("http")) { + + isImportingRepo = true; + // QRCode are more efficient in all upper case, so some incoming // URLs might be encoded in all upper case. Therefore, we allow // the standard paths to be encoded all upper case, then they'll @@ -255,7 +264,7 @@ public class ManageRepo extends ListActivity { @Override public void onClick(DialogInterface dialog, int which) { setResult(Activity.RESULT_CANCELED); - if (getCallingActivity() != null) { + if (isImportingRepo) { finish(); } } @@ -340,7 +349,7 @@ public class ManageRepo extends ListActivity { */ private void finishedAddingRepo() { changed = true; - if (getCallingActivity() != null) { + if (isImportingRepo) { setResult(Activity.RESULT_OK); finish(); } else { diff --git a/src/org/fdroid/fdroid/views/RepoAdapter.java b/src/org/fdroid/fdroid/views/RepoAdapter.java index 7d3ecd156..e68c8bf3c 100644 --- a/src/org/fdroid/fdroid/views/RepoAdapter.java +++ b/src/org/fdroid/fdroid/views/RepoAdapter.java @@ -74,8 +74,7 @@ public class RepoAdapter extends BaseAdapter { }); int unsignedVisibility = repository.isSigned() ? View.GONE : View.VISIBLE; - view.findViewById(R.id.repo_not_signed).setVisibility - (unsignedVisibility); + view.findViewById(R.id.repo_unsigned).setVisibility(unsignedVisibility); TextView nameView = (TextView)view.findViewById(R.id.repo_name); nameView.setText(repository.getName()); diff --git a/src/org/fdroid/fdroid/views/fragments/RepoDetailsFragment.java b/src/org/fdroid/fdroid/views/fragments/RepoDetailsFragment.java index c2a6c467b..fb670538a 100644 --- a/src/org/fdroid/fdroid/views/fragments/RepoDetailsFragment.java +++ b/src/org/fdroid/fdroid/views/fragments/RepoDetailsFragment.java @@ -45,6 +45,7 @@ public class RepoDetailsFragment extends Fragment { }; private static final int DELETE = 0; + private static final int UPDATE = 1; public void setRepoChangeListener(OnRepoChangeListener listener) { repoChangeListener = listener; @@ -71,16 +72,6 @@ public class RepoDetailsFragment extends Fragment { } - private ProgressListener updateProgressListener = new ProgressListener() { - @Override - public void onProgress(Event event) { - if (event.type == UpdateService.STATUS_COMPLETE) { - reloadRepoDetails(); - updateView((ViewGroup)getView()); - } - } - }; - // TODO: Currently initialised in onCreateView. Not sure if that is the // best way to go about this... private DB.Repo repo; @@ -125,7 +116,12 @@ public class RepoDetailsFragment extends Fragment { inputUrl.addTextChangedListener(new UrlWatcher()); Button update = (Button)repoView.findViewById(R.id.btn_update); - update.setOnClickListener(new UpdateListener()); + update.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + performUpdate(); + } + }); return repoView; } @@ -171,17 +167,22 @@ public class RepoDetailsFragment extends Fragment { } /** - * When the update button is clicked, notify the listener so that the repo + * When an update is performed, notify the listener so that the repo * list can be updated. We will perform the update ourselves though. */ - class UpdateListener implements View.OnClickListener { - - @Override - public void onClick(View v) { - UpdateService.updateNow(getActivity()).setListener(updateProgressListener); - if (repoChangeListener != null) { - repoChangeListener.onUpdatePerformed(repo); + private void performUpdate() { + UpdateService.updateNow(getActivity()).setListener(new ProgressListener() { + @Override + public void onProgress(Event event) { + if (event.type == UpdateService.STATUS_COMPLETE_AND_SAME || + event.type == UpdateService.STATUS_COMPLETE_WITH_CHANGES) { + reloadRepoDetails(); + updateView((ViewGroup)getView()); + } } + }); + if (repoChangeListener != null) { + repoChangeListener.onUpdatePerformed(repo); } } @@ -208,11 +209,19 @@ public class RepoDetailsFragment extends Fragment { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); menu.clear(); + + MenuItem update = menu.add(Menu.NONE, UPDATE, 0, R.string.repo_update); + update.setIcon(R.drawable.ic_menu_refresh); + MenuItemCompat.setShowAsAction(update, + MenuItemCompat.SHOW_AS_ACTION_ALWAYS | + MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT ); + MenuItem delete = menu.add(Menu.NONE, DELETE, 0, R.string.delete); delete.setIcon(android.R.drawable.ic_menu_delete); MenuItemCompat.setShowAsAction(delete, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); + } @Override @@ -221,6 +230,9 @@ public class RepoDetailsFragment extends Fragment { if (item.getItemId() == DELETE) { promptForDelete(); return true; + } else if (item.getItemId() == UPDATE) { + performUpdate(); + return true; } return false;