Added update button to repo details screen.
This commit is contained in:
parent
82af6fc60e
commit
4fdc23569b
@ -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>
|
||||
|
@ -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"/>
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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 {
|
||||
|
@ -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());
|
||||
|
@ -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,19 +167,24 @@ 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 {
|
||||
|
||||
private void performUpdate() {
|
||||
UpdateService.updateNow(getActivity()).setListener(new ProgressListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
UpdateService.updateNow(getActivity()).setListener(updateProgressListener);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When the URL is changed, notify the repoChangeListener.
|
||||
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user