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_toRightOf="@id/img"
|
||||||
android:layout_alignParentLeft="true"/>
|
android:layout_alignParentLeft="true"/>
|
||||||
|
|
||||||
<TextView android:id="@+id/repo_not_signed"
|
<TextView android:id="@+id/repo_unsigned"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/repo_name"
|
android:layout_below="@id/repo_name"
|
||||||
android:textColor="@color/unsigned"
|
android:text="@string/unsigned"
|
||||||
android:text="@string/unsigned" />
|
android:textColor="@color/unsigned"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
@ -123,7 +123,7 @@
|
|||||||
<Button
|
<Button
|
||||||
android:id="@+id/btn_update"
|
android:id="@+id/btn_update"
|
||||||
android:layout_centerHorizontal="true"
|
android:layout_centerHorizontal="true"
|
||||||
android:text="@string/update"
|
android:text="@string/repo_update"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/text_not_yet_updated"/>
|
android:layout_below="@id/text_not_yet_updated"/>
|
||||||
|
@ -166,6 +166,7 @@
|
|||||||
<string name="repo_signature">Signature</string>
|
<string name="repo_signature">Signature</string>
|
||||||
<string name="repo_description">Description</string>
|
<string name="repo_description">Description</string>
|
||||||
<string name="repo_last_update">Last update</string>
|
<string name="repo_last_update">Last update</string>
|
||||||
|
<string name="repo_update">Update</string>
|
||||||
<string name="repo_name">Name</string>
|
<string name="repo_name">Name</string>
|
||||||
<string name="unsigned_description">This means that the list of
|
<string name="unsigned_description">This means that the list of
|
||||||
applications could not be verified. You should be careful
|
applications could not be verified. You should be careful
|
||||||
|
@ -535,6 +535,10 @@ public class DB {
|
|||||||
public boolean isSigned() {
|
public boolean isSigned() {
|
||||||
return this.pubkey != null && this.pubkey.length() > 0;
|
return this.pubkey != null && this.pubkey.length() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasBeenUpdated() {
|
||||||
|
return this.lastetag != null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final int DBVersion = 31;
|
private final int DBVersion = 31;
|
||||||
|
@ -65,6 +65,12 @@ public class ManageRepo extends ListActivity {
|
|||||||
|
|
||||||
private RepoAdapter repoAdapter;
|
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
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
@ -108,6 +114,9 @@ public class ManageRepo extends ListActivity {
|
|||||||
String host = uri.getHost().toLowerCase(Locale.ENGLISH);
|
String host = uri.getHost().toLowerCase(Locale.ENGLISH);
|
||||||
if (scheme.equals("fdroidrepos") || scheme.equals("fdroidrepo")
|
if (scheme.equals("fdroidrepos") || scheme.equals("fdroidrepo")
|
||||||
|| scheme.equals("https") || scheme.equals("http")) {
|
|| scheme.equals("https") || scheme.equals("http")) {
|
||||||
|
|
||||||
|
isImportingRepo = true;
|
||||||
|
|
||||||
// QRCode are more efficient in all upper case, so some incoming
|
// QRCode are more efficient in all upper case, so some incoming
|
||||||
// URLs might be encoded in all upper case. Therefore, we allow
|
// URLs might be encoded in all upper case. Therefore, we allow
|
||||||
// the standard paths to be encoded all upper case, then they'll
|
// the standard paths to be encoded all upper case, then they'll
|
||||||
@ -255,7 +264,7 @@ public class ManageRepo extends ListActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
setResult(Activity.RESULT_CANCELED);
|
setResult(Activity.RESULT_CANCELED);
|
||||||
if (getCallingActivity() != null) {
|
if (isImportingRepo) {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -340,7 +349,7 @@ public class ManageRepo extends ListActivity {
|
|||||||
*/
|
*/
|
||||||
private void finishedAddingRepo() {
|
private void finishedAddingRepo() {
|
||||||
changed = true;
|
changed = true;
|
||||||
if (getCallingActivity() != null) {
|
if (isImportingRepo) {
|
||||||
setResult(Activity.RESULT_OK);
|
setResult(Activity.RESULT_OK);
|
||||||
finish();
|
finish();
|
||||||
} else {
|
} else {
|
||||||
|
@ -74,8 +74,7 @@ public class RepoAdapter extends BaseAdapter {
|
|||||||
});
|
});
|
||||||
|
|
||||||
int unsignedVisibility = repository.isSigned() ? View.GONE : View.VISIBLE;
|
int unsignedVisibility = repository.isSigned() ? View.GONE : View.VISIBLE;
|
||||||
view.findViewById(R.id.repo_not_signed).setVisibility
|
view.findViewById(R.id.repo_unsigned).setVisibility(unsignedVisibility);
|
||||||
(unsignedVisibility);
|
|
||||||
|
|
||||||
TextView nameView = (TextView)view.findViewById(R.id.repo_name);
|
TextView nameView = (TextView)view.findViewById(R.id.repo_name);
|
||||||
nameView.setText(repository.getName());
|
nameView.setText(repository.getName());
|
||||||
|
@ -45,6 +45,7 @@ public class RepoDetailsFragment extends Fragment {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private static final int DELETE = 0;
|
private static final int DELETE = 0;
|
||||||
|
private static final int UPDATE = 1;
|
||||||
|
|
||||||
public void setRepoChangeListener(OnRepoChangeListener listener) {
|
public void setRepoChangeListener(OnRepoChangeListener listener) {
|
||||||
repoChangeListener = 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
|
// TODO: Currently initialised in onCreateView. Not sure if that is the
|
||||||
// best way to go about this...
|
// best way to go about this...
|
||||||
private DB.Repo repo;
|
private DB.Repo repo;
|
||||||
@ -125,7 +116,12 @@ public class RepoDetailsFragment extends Fragment {
|
|||||||
inputUrl.addTextChangedListener(new UrlWatcher());
|
inputUrl.addTextChangedListener(new UrlWatcher());
|
||||||
|
|
||||||
Button update = (Button)repoView.findViewById(R.id.btn_update);
|
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;
|
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.
|
* 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
|
@Override
|
||||||
public void onClick(View v) {
|
public void onProgress(Event event) {
|
||||||
UpdateService.updateNow(getActivity()).setListener(updateProgressListener);
|
if (event.type == UpdateService.STATUS_COMPLETE_AND_SAME ||
|
||||||
if (repoChangeListener != null) {
|
event.type == UpdateService.STATUS_COMPLETE_WITH_CHANGES) {
|
||||||
repoChangeListener.onUpdatePerformed(repo);
|
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) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
super.onCreateOptionsMenu(menu, inflater);
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
menu.clear();
|
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);
|
MenuItem delete = menu.add(Menu.NONE, DELETE, 0, R.string.delete);
|
||||||
delete.setIcon(android.R.drawable.ic_menu_delete);
|
delete.setIcon(android.R.drawable.ic_menu_delete);
|
||||||
MenuItemCompat.setShowAsAction(delete,
|
MenuItemCompat.setShowAsAction(delete,
|
||||||
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM |
|
MenuItemCompat.SHOW_AS_ACTION_IF_ROOM |
|
||||||
MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT);
|
MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -221,6 +230,9 @@ public class RepoDetailsFragment extends Fragment {
|
|||||||
if (item.getItemId() == DELETE) {
|
if (item.getItemId() == DELETE) {
|
||||||
promptForDelete();
|
promptForDelete();
|
||||||
return true;
|
return true;
|
||||||
|
} else if (item.getItemId() == UPDATE) {
|
||||||
|
performUpdate();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user