Merge "Convert CA loading from spinning wheel to progress bar"
This commit is contained in:
committed by
Android (Google) Code Review
commit
abb56b185b
@@ -42,8 +42,8 @@
|
|||||||
>
|
>
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/system_progress"
|
android:id="@+id/system_progress"
|
||||||
style="?android:attr/progressBarStyleLarge"
|
style="?android:attr/progressBarStyleHorizontal"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
/>
|
/>
|
||||||
|
@@ -36,6 +36,7 @@ import android.widget.Button;
|
|||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TabHost;
|
import android.widget.TabHost;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import java.security.cert.CertificateEncodingException;
|
import java.security.cert.CertificateEncodingException;
|
||||||
@@ -210,15 +211,21 @@ public class TrustedCredentialsSettings extends Fragment {
|
|||||||
return view;
|
return view;
|
||||||
};
|
};
|
||||||
|
|
||||||
private class AliasLoader extends AsyncTask<Void, Void, List<CertHolder>> {
|
private class AliasLoader extends AsyncTask<Void, Integer, List<CertHolder>> {
|
||||||
|
ProgressBar mProgressBar;
|
||||||
|
View mList;
|
||||||
@Override protected void onPreExecute() {
|
@Override protected void onPreExecute() {
|
||||||
View content = mTabHost.getTabContentView();
|
View content = mTabHost.getTabContentView();
|
||||||
content.findViewById(mTab.mProgress).setVisibility(View.VISIBLE);
|
mProgressBar = (ProgressBar) content.findViewById(mTab.mProgress);
|
||||||
content.findViewById(mTab.mList).setVisibility(View.GONE);
|
mList = content.findViewById(mTab.mList);
|
||||||
|
mProgressBar.setVisibility(View.VISIBLE);
|
||||||
|
mList.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
@Override protected List<CertHolder> doInBackground(Void... params) {
|
@Override protected List<CertHolder> doInBackground(Void... params) {
|
||||||
Set<String> aliases = mTab.getAliases(mStore);
|
Set<String> aliases = mTab.getAliases(mStore);
|
||||||
List<CertHolder> certHolders = new ArrayList<CertHolder>(aliases.size());
|
int max = aliases.size();
|
||||||
|
int progress = 0;
|
||||||
|
List<CertHolder> certHolders = new ArrayList<CertHolder>(max);
|
||||||
for (String alias : aliases) {
|
for (String alias : aliases) {
|
||||||
X509Certificate cert = (X509Certificate) mStore.getCertificate(alias, true);
|
X509Certificate cert = (X509Certificate) mStore.getCertificate(alias, true);
|
||||||
certHolders.add(new CertHolder(mStore,
|
certHolders.add(new CertHolder(mStore,
|
||||||
@@ -226,10 +233,19 @@ public class TrustedCredentialsSettings extends Fragment {
|
|||||||
mTab,
|
mTab,
|
||||||
alias,
|
alias,
|
||||||
cert));
|
cert));
|
||||||
|
publishProgress(++progress, max);
|
||||||
}
|
}
|
||||||
Collections.sort(certHolders);
|
Collections.sort(certHolders);
|
||||||
return certHolders;
|
return certHolders;
|
||||||
}
|
}
|
||||||
|
@Override protected void onProgressUpdate(Integer... progressAndMax) {
|
||||||
|
int progress = progressAndMax[0];
|
||||||
|
int max = progressAndMax[1];
|
||||||
|
if (max != mProgressBar.getMax()) {
|
||||||
|
mProgressBar.setMax(max);
|
||||||
|
}
|
||||||
|
mProgressBar.setProgress(progress);
|
||||||
|
}
|
||||||
@Override protected void onPostExecute(List<CertHolder> certHolders) {
|
@Override protected void onPostExecute(List<CertHolder> certHolders) {
|
||||||
mCertHolders.clear();
|
mCertHolders.clear();
|
||||||
mCertHolders.addAll(certHolders);
|
mCertHolders.addAll(certHolders);
|
||||||
|
Reference in New Issue
Block a user