Revision 46be3ddf
Added by Leszek Koltunski almost 4 years ago
| src/main/java/org/distorted/dialogs/RubikDialogScoresPagerAdapter.java | ||
|---|---|---|
| 38 | 38 |  | 
| 39 | 39 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 40 | 40 |  | 
| 41 | class RubikDialogScoresPagerAdapter extends PagerAdapter implements RubikNetwork.Receiver | |
| 41 | class RubikDialogScoresPagerAdapter extends PagerAdapter implements RubikNetwork.ScoresReceiver
 | |
| 42 | 42 |   {
 | 
| 43 | 43 | private final FragmentActivity mAct; | 
| 44 | 44 | private final RubikDialogScores mDialog; | 
| ... | ... | |
| 157 | 157 |  | 
| 158 | 158 | switch(errorNumber) | 
| 159 | 159 |       {
 | 
| 160 |       case '1': message("Network error");
 | |
| 160 |       case '1': message(mAct.getString(R.string.networkError));
 | |
| 161 | 161 | break; | 
| 162 | 162 | case '2': RubikScores scores = RubikScores.getInstance(); | 
| 163 | 163 | Bundle bundle = new Bundle(); | 
| src/main/java/org/distorted/dialogs/RubikDialogUpdateView.java | ||
|---|---|---|
| 21 | 21 |  | 
| 22 | 22 | import android.app.Activity; | 
| 23 | 23 | import android.graphics.Bitmap; | 
| 24 | import android.graphics.Color; | |
| 24 | 25 | import android.util.TypedValue; | 
| 25 | 26 | import android.view.View; | 
| 26 | 27 | import android.widget.Button; | 
| ... | ... | |
| 30 | 31 | import android.widget.TextView; | 
| 31 | 32 |  | 
| 32 | 33 | import org.distorted.main.R; | 
| 34 | import org.distorted.network.RubikNetwork; | |
| 33 | 35 | import org.distorted.network.RubikUpdates; | 
| 34 | 36 |  | 
| 37 | import java.io.InputStream; | |
| 38 |  | |
| 35 | 39 | import static android.view.View.GONE; | 
| 40 | import static android.view.View.VISIBLE; | |
| 36 | 41 |  | 
| 37 | 42 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 38 | 43 |  | 
| 39 | public class RubikDialogUpdateView | |
| 44 | public class RubikDialogUpdateView implements RubikNetwork.Downloadee
 | |
| 40 | 45 |   {
 | 
| 41 | 46 | private ImageView mIcon; | 
| 47 | private RubikUpdates.UpdateInfo mInfo; | |
| 48 | private ProgressBar mBar; | |
| 49 | private Button mButton; | |
| 50 | private TextView mDescription; | |
| 42 | 51 |  | 
| 43 | 52 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 44 | 53 |  | 
| 45 | 54 | public View createView(Activity act, RubikUpdates.UpdateInfo info, int fontSize, int padding, | 
| 46 | 55 | LinearLayout.LayoutParams pView, LinearLayout.LayoutParams pText, LinearLayout.LayoutParams pButt ) | 
| 47 | 56 |     {
 | 
| 57 | mInfo = info; | |
| 58 | final RubikNetwork.Downloadee downloadee = this; | |
| 48 | 59 | View view = act.getLayoutInflater().inflate(R.layout.dialog_updates_pane, null); | 
| 49 | 60 | TextView title = view.findViewById(R.id.updates_pane_title); | 
| 50 | 61 | title.setText(info.mObjectLongName); | 
| 51 |     TextView description = view.findViewById(R.id.updates_pane_description);
 | |
| 52 |     description.setText(info.mDescription);
 | |
| 62 |     mDescription = view.findViewById(R.id.updates_pane_description);
 | |
| 63 |     mDescription.setText(info.mDescription);
 | |
| 53 | 64 |  | 
| 54 | 65 | mIcon = view.findViewById(R.id.updates_pane_image); | 
| 55 | 66 | mIcon.setImageResource(R.drawable.unknown_icon); | 
| ... | ... | |
| 57 | 68 | view.setLayoutParams(pView); | 
| 58 | 69 |  | 
| 59 | 70 | title.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize); | 
| 60 |     description.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize);
 | |
| 71 |     mDescription.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize);
 | |
| 61 | 72 |  | 
| 62 | 73 | title.setLayoutParams(pText); | 
| 63 |     description.setLayoutParams(pText);
 | |
| 74 |     mDescription.setLayoutParams(pText);
 | |
| 64 | 75 |  | 
| 65 | 76 | view.setPadding(padding,padding,padding,padding); | 
| 66 | 77 |  | 
| 67 |     ProgressBar bar = view.findViewById(R.id.updates_pane_bar);
 | |
| 68 |     Button button   = view.findViewById(R.id.updates_pane_button);
 | |
| 78 |     mBar    = view.findViewById(R.id.updates_pane_bar);
 | |
| 79 |     mButton = view.findViewById(R.id.updates_pane_button);
 | |
| 69 | 80 |  | 
| 70 | 81 | if( info.mPercent>=100 ) | 
| 71 | 82 |       {
 | 
| 72 |       bar.setVisibility(GONE);
 | |
| 73 |       button.setOnClickListener( new View.OnClickListener()
 | |
| 83 |       mBar.setVisibility(GONE);
 | |
| 84 |       mButton.setOnClickListener( new View.OnClickListener()
 | |
| 74 | 85 |         {
 | 
| 75 | 86 | @Override | 
| 76 | 87 | public void onClick(View v) | 
| 77 | 88 |           {
 | 
| 78 |           android.util.Log.e("D", "INSTALL pressed");
 | |
| 89 | startDownload(); | |
| 90 | RubikNetwork network = RubikNetwork.getInstance(); | |
| 91 | network.downloadJSON(info,downloadee); | |
| 79 | 92 | } | 
| 80 | 93 | }); | 
| 81 | 94 |  | 
| 82 | button.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize); | |
| 83 | button.setLayoutParams(pButt); | |
| 95 | mButton.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize); | |
| 96 | mButton.setLayoutParams(pButt); | |
| 97 | mBar.setLayoutParams(pButt); | |
| 84 | 98 | } | 
| 85 | 99 | else | 
| 86 | 100 |       {
 | 
| 87 |       button.setVisibility(GONE);
 | |
| 88 |       bar.setLayoutParams(pButt);
 | |
| 89 |       bar.setProgress(info.mPercent);
 | |
| 101 |       mButton.setVisibility(GONE);
 | |
| 102 |       mBar.setLayoutParams(pButt);
 | |
| 103 |       mBar.setProgress(info.mPercent);
 | |
| 90 | 104 | } | 
| 91 | 105 |  | 
| 92 | 106 | return view; | 
| ... | ... | |
| 98 | 112 |     {
 | 
| 99 | 113 | mIcon.setImageBitmap(icon); | 
| 100 | 114 | } | 
| 115 |  | |
| 116 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 117 |  | |
| 118 | private void startDownload() | |
| 119 |     {
 | |
| 120 | mDescription.setText(R.string.downloading); | |
| 121 | mBar.setProgress(20); | |
| 122 | mButton.setVisibility(GONE); | |
| 123 | mBar.setVisibility(VISIBLE); | |
| 124 | } | |
| 125 |  | |
| 126 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 127 |  | |
| 128 | public void jsonDownloaded() | |
| 129 |     {
 | |
| 130 | if( mInfo.mUpdateObject && mInfo.mObjectStream==null ) | |
| 131 |       {
 | |
| 132 |       mDescription.setTextColor(Color.parseColor("#ff0000"));
 | |
| 133 | mDescription.setText(R.string.networkError); | |
| 134 | } | |
| 135 | else | |
| 136 |       {
 | |
| 137 | mBar.setProgress(50); | |
| 138 | mDescription.setText(R.string.installing); | |
| 139 | } | |
| 140 | } | |
| 101 | 141 | } | 
| src/main/java/org/distorted/dialogs/RubikDialogUpdates.java | ||
|---|---|---|
| 46 | 46 |  | 
| 47 | 47 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 48 | 48 |  | 
| 49 | public class RubikDialogUpdates extends AppCompatDialogFragment implements RubikNetwork.Updatee | |
| 49 | public class RubikDialogUpdates extends AppCompatDialogFragment implements RubikNetwork.IconReceiver, RubikNetwork.Updatee
 | |
| 50 | 50 |   {
 | 
| 51 | 51 | private TextView mText; | 
| 52 | 52 | private LinearLayout mLayout; | 
| ... | ... | |
| 218 | 218 |  | 
| 219 | 219 | public void errorUpdate() | 
| 220 | 220 |     {
 | 
| 221 |     mText.setText("Network error");
 | |
| 221 | FragmentActivity act = getActivity(); | |
| 222 | if( act!=null ) mText.setText(act.getString(R.string.networkError)); | |
| 222 | 223 | } | 
| 223 | 224 |  | 
| 224 | 225 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| src/main/java/org/distorted/network/RubikNetwork.java | ||
|---|---|---|
| 46 | 46 |  | 
| 47 | 47 | public class RubikNetwork | 
| 48 | 48 |   {
 | 
| 49 | public interface Receiver | |
| 49 |   public interface ScoresReceiver
 | |
| 50 | 50 |     {
 | 
| 51 | 51 | void receive(String[][][] country, String[][][] name, float[][][] time); | 
| 52 | 52 | void message(String mess); | 
| 53 | 53 | void error(String error); | 
| 54 | 54 | } | 
| 55 | 55 |  | 
| 56 |   public interface Updatee
 | |
| 56 |   public interface IconReceiver
 | |
| 57 | 57 |     {
 | 
| 58 | 58 | void iconDownloaded(int ordinal, Bitmap bitmap); | 
| 59 | } | |
| 60 |  | |
| 61 | public interface Updatee | |
| 62 |     {
 | |
| 59 | 63 | void receiveUpdate(RubikUpdates update); | 
| 60 | 64 | void errorUpdate(); | 
| 61 | 65 | } | 
| 62 | 66 |  | 
| 67 | public interface Downloadee | |
| 68 |     {
 | |
| 69 | void jsonDownloaded(); | |
| 70 | } | |
| 71 |  | |
| 63 | 72 | public static final int MAX_PLACES = 10; | 
| 64 | 73 |  | 
| 65 | 74 | private static final int REND_ADRENO= 0; | 
| ... | ... | |
| 114 | 123 | private static RubikNetwork mThis; | 
| 115 | 124 | private static String mScores = ""; | 
| 116 | 125 | private static boolean mRunning = false; | 
| 117 | private static Receiver mReceiver; | |
| 118 | 126 | private static Updatee mUpdatee; | 
| 119 | 127 | private static String mVersion; | 
| 120 | private static String mSuspicious; | |
| 121 | 128 | private static int mNumObjects; | 
| 122 | 129 | private static RubikUpdates mUpdates; | 
| 123 | 130 | private static int mDebugState; | 
| ... | ... | |
| 168 | 175 |  | 
| 169 | 176 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 170 | 177 |  | 
| 171 | private boolean fillValuesNormal() | |
| 178 |   private boolean fillValuesNormal(ScoresReceiver receiver)
 | |
| 172 | 179 |     {
 | 
| 173 | 180 | int begin=-1 ,end, len = mScores.length(); | 
| 174 | 181 | String row; | 
| 175 | 182 |  | 
| 176 | 183 | if( len==0 ) | 
| 177 | 184 |       {
 | 
| 178 |       if( mReceiver!=null ) mReceiver.error("1");
 | |
| 185 |       receiver.error("1");
 | |
| 179 | 186 | return false; | 
| 180 | 187 | } | 
| 181 | 188 | else if( len<=2 ) | 
| 182 | 189 |       {
 | 
| 183 |       if( mReceiver!=null ) mReceiver.error(mScores);
 | |
| 190 |       receiver.error(mScores);
 | |
| 184 | 191 | return false; | 
| 185 | 192 | } | 
| 186 | 193 |  | 
| ... | ... | |
| 376 | 383 |  | 
| 377 | 384 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 378 | 385 |  | 
| 379 | private boolean network(String url) | |
| 386 |   private boolean network(String url, ScoresReceiver receiver)
 | |
| 380 | 387 |     {
 | 
| 381 | 388 | try | 
| 382 | 389 |       {
 | 
| ... | ... | |
| 400 | 407 | } | 
| 401 | 408 |  | 
| 402 | 409 | mScores = total.toString(); | 
| 410 | conn.disconnect(); | |
| 403 | 411 | } | 
| 404 | 412 | catch( final UnknownHostException e ) | 
| 405 | 413 |       {
 | 
| 406 |       if( mReceiver!=null ) mReceiver.message("No access to Internet");
 | |
| 414 |       receiver.message("No access to Internet");
 | |
| 407 | 415 | return false; | 
| 408 | 416 | } | 
| 409 | 417 | catch( final SecurityException e ) | 
| 410 | 418 |       {
 | 
| 411 |       if( mReceiver!=null ) mReceiver.message("Application not authorized to connect to the Internet");
 | |
| 419 |       receiver.message("Application not authorized to connect to the Internet");
 | |
| 412 | 420 | return false; | 
| 413 | 421 | } | 
| 414 | 422 | catch( final Exception e ) | 
| 415 | 423 |       {
 | 
| 416 |       if( mReceiver!=null ) mReceiver.message(e.getMessage());
 | |
| 424 |       receiver.message(e.getMessage());
 | |
| 417 | 425 | return false; | 
| 418 | 426 | } | 
| 419 | 427 |  | 
| 420 | 428 | if( mScores.length()==0 ) | 
| 421 | 429 |       {
 | 
| 422 |       if( mReceiver!=null ) mReceiver.message("Failed to download scores");
 | |
| 430 |       receiver.message("Failed to download scores");
 | |
| 423 | 431 | return false; | 
| 424 | 432 | } | 
| 425 | 433 |  | 
| ... | ... | |
| 428 | 436 |  | 
| 429 | 437 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 430 | 438 |  | 
| 431 | private String constructSuspiciousURL() | |
| 439 |   private String constructSuspiciousURL(String suspURL)
 | |
| 432 | 440 |     {
 | 
| 433 | 441 | RubikScores scores = RubikScores.getInstance(); | 
| 434 | 442 | int deviceID= scores.getDeviceID(); | 
| 435 |     String suspicious = URLencode(mSuspicious);
 | |
| 443 |     String suspicious = URLencode(suspURL);
 | |
| 436 | 444 |  | 
| 437 | 445 | String url="https://distorted.org/magic/cgi-bin/suspicious.cgi"; | 
| 438 | 446 | url += "?i="+deviceID+"&d="+suspicious; | 
| ... | ... | |
| 534 | 542 |  | 
| 535 | 543 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 536 | 544 |  | 
| 537 | private void downloadThread() | |
| 545 |   private void downloadThread(ScoresReceiver receiver)
 | |
| 538 | 546 |     {
 | 
| 539 | 547 | try | 
| 540 | 548 |       {
 | 
| 541 | 549 | if( gottaDownload() ) | 
| 542 | 550 |         {
 | 
| 543 | 551 | mRunning = true; | 
| 544 | boolean receiveValues = network(constructDownloadURL()); | |
| 552 |         boolean receiveValues = network(constructDownloadURL(),receiver);
 | |
| 545 | 553 |  | 
| 546 | 554 | if( mRunning ) | 
| 547 | 555 |           {
 | 
| 548 | receiveValues = fillValuesNormal(); | |
| 556 |           receiveValues = fillValuesNormal(receiver);
 | |
| 549 | 557 | mRunning = false; | 
| 550 | 558 | } | 
| 551 | 559 |  | 
| 552 |         if( receiveValues && mReceiver!=null ) mReceiver.receive(mCountry, mName, mTime);
 | |
| 560 |         if( receiveValues ) receiver.receive(mCountry, mName, mTime);
 | |
| 553 | 561 | } | 
| 554 | 562 | } | 
| 555 | 563 | catch( Exception e ) | 
| 556 | 564 |       {
 | 
| 557 |       if( mReceiver!=null ) mReceiver.message("Exception downloading records: "+e.getMessage() );
 | |
| 565 |       receiver.message("Exception downloading records: "+e.getMessage() );
 | |
| 558 | 566 | } | 
| 559 | 567 | } | 
| 560 | 568 |  | 
| 561 | 569 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 562 | 570 |  | 
| 563 | private void submitThread() | |
| 571 |   private void submitThread(ScoresReceiver receiver)
 | |
| 564 | 572 |     {
 | 
| 565 | 573 | try | 
| 566 | 574 |       {
 | 
| ... | ... | |
| 569 | 577 |  | 
| 570 | 578 | if( scores.thereAreUnsubmittedRecords() ) | 
| 571 | 579 |         {
 | 
| 572 | boolean receiveValues = network(constructSubmitURL()); | |
| 580 |         boolean receiveValues = network(constructSubmitURL(),receiver);
 | |
| 573 | 581 |  | 
| 574 | 582 | if( mRunning ) | 
| 575 | 583 |           {
 | 
| 576 | receiveValues = fillValuesNormal(); | |
| 584 |           receiveValues = fillValuesNormal(receiver);
 | |
| 577 | 585 | mRunning = false; | 
| 578 | 586 | } | 
| 579 | 587 |  | 
| 580 | 588 | if( receiveValues ) | 
| 581 | 589 |           {
 | 
| 582 | 590 | RubikScores.getInstance().successfulSubmit(); | 
| 583 |           if( mReceiver!=null ) mReceiver.receive(mCountry, mName, mTime);
 | |
| 591 |           receiver.receive(mCountry, mName, mTime);
 | |
| 584 | 592 | } | 
| 585 | 593 | } | 
| 586 | 594 | } | 
| 587 | 595 | catch( Exception e ) | 
| 588 | 596 |       {
 | 
| 589 |       if( mReceiver!=null ) mReceiver.message("Exception submitting records: "+e.getMessage() );
 | |
| 597 |       receiver.message("Exception submitting records: "+e.getMessage() );
 | |
| 590 | 598 | } | 
| 591 | 599 | } | 
| 592 | 600 |  | 
| ... | ... | |
| 621 | 629 | } | 
| 622 | 630 |  | 
| 623 | 631 | String updates = answer.toString(); | 
| 632 | conn.disconnect(); | |
| 624 | 633 | mUpdates.parse(updates); | 
| 625 | 634 |  | 
| 626 | 635 | if( mUpdatee!=null ) mUpdatee.receiveUpdate(mUpdates); | 
| ... | ... | |
| 635 | 644 |  | 
| 636 | 645 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 637 | 646 |  | 
| 638 | private void suspiciousThread() | |
| 647 |   private void suspiciousThread(String suspURL)
 | |
| 639 | 648 |     {
 | 
| 640 | String url = constructSuspiciousURL(); | |
| 649 |     String url = constructSuspiciousURL(suspURL);
 | |
| 641 | 650 |  | 
| 642 | 651 | try | 
| 643 | 652 |       {
 | 
| ... | ... | |
| 651 | 660 | conn.connect(); | 
| 652 | 661 | conn.getOutputStream().flush(); | 
| 653 | 662 | conn.getInputStream(); | 
| 663 | conn.disconnect(); | |
| 654 | 664 | } | 
| 655 | 665 | catch( final Exception e ) | 
| 656 | 666 |       {
 | 
| ... | ... | |
| 664 | 674 |     {
 | 
| 665 | 675 | try | 
| 666 | 676 |       {
 | 
| 667 |       android.util.Log.e("D", "downloading "+url);
 | |
| 668 |  | |
| 669 | 677 | java.net.URL connectURL = new URL(url); | 
| 670 | 678 | HttpURLConnection conn = (HttpURLConnection) connectURL.openConnection(); | 
| 671 | 679 | conn.setDoInput(true); | 
| 672 | 680 | conn.connect(); | 
| 673 | 681 | InputStream input = conn.getInputStream(); | 
| 674 | return BitmapFactory.decodeStream(input); | |
| 682 | Bitmap icon = BitmapFactory.decodeStream(input); | |
| 683 | conn.disconnect(); | |
| 684 | return icon; | |
| 675 | 685 | } | 
| 676 | 686 | catch (IOException e) | 
| 677 | 687 |       {
 | 
| ... | ... | |
| 683 | 693 |  | 
| 684 | 694 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 685 | 695 |  | 
| 686 | private void iconThread() | |
| 696 |   private void iconThread(IconReceiver receiver)
 | |
| 687 | 697 |     {
 | 
| 688 | 698 | int numC = mUpdates.getCompletedNumber(); | 
| 689 | 699 | int numS = mUpdates.getStartedNumber(); | 
| ... | ... | |
| 704 | 714 | if( icon!=null ) | 
| 705 | 715 |           {
 | 
| 706 | 716 | mUpdates.setCompletedIcon(c,icon); | 
| 707 |           mUpdatee.iconDownloaded(c,icon);
 | |
| 717 |           receiver.iconDownloaded(c,icon);
 | |
| 708 | 718 | } | 
| 709 | 719 | } | 
| 710 | 720 | } | 
| ... | ... | |
| 725 | 735 | if( icon!=null ) | 
| 726 | 736 |           {
 | 
| 727 | 737 | mUpdates.setStartedIcon(s,icon); | 
| 728 |           mUpdatee.iconDownloaded(numC+s,icon);
 | |
| 738 |           receiver.iconDownloaded(numC+s,icon);
 | |
| 729 | 739 | } | 
| 730 | 740 | } | 
| 731 | 741 | } | 
| 732 | 742 | } | 
| 733 | 743 |  | 
| 744 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 745 |  | |
| 746 | private InputStream downloadJSON(String name) | |
| 747 |     {
 | |
| 748 | String url = mUpdates.getURL() + name; | |
| 749 |  | |
| 750 | try | |
| 751 |       {
 | |
| 752 | java.net.URL connectURL = new URL(url); | |
| 753 | HttpURLConnection conn = (HttpURLConnection) connectURL.openConnection(); | |
| 754 | conn.setDoInput(true); | |
| 755 | conn.connect(); | |
| 756 | InputStream stream = conn.getInputStream(); | |
| 757 | conn.disconnect(); | |
| 758 | return stream; | |
| 759 | } | |
| 760 | catch (IOException e) | |
| 761 |       {
 | |
| 762 |       android.util.Log.e("D", "Failed to download "+url);
 | |
| 763 |       android.util.Log.e("D", e.getMessage() );
 | |
| 764 | return null; | |
| 765 | } | |
| 766 | } | |
| 767 |  | |
| 768 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 769 |  | |
| 770 | private void jsonThread(final RubikUpdates.UpdateInfo info, Downloadee downloadee) | |
| 771 |     {
 | |
| 772 | if(info.mUpdateObject) info.mObjectStream = downloadJSON(info.mObjectShortName+"_object.json"); | |
| 773 | if(info.mUpdateExtras) info.mExtrasStream = downloadJSON(info.mObjectShortName+"_extras.json"); | |
| 774 |  | |
| 775 | downloadee.jsonDownloaded(); | |
| 776 | } | |
| 777 |  | |
| 734 | 778 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 735 | 779 |  | 
| 736 | 780 | private RubikNetwork() | 
| ... | ... | |
| 761 | 805 |  | 
| 762 | 806 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 763 | 807 |  | 
| 764 |   public void download(Receiver receiver, FragmentActivity act)
 | |
| 808 |   public void download(final ScoresReceiver receiver, final FragmentActivity act)
 | |
| 765 | 809 |     {
 | 
| 766 | 810 | initializeStatics(); | 
| 767 | mReceiver = receiver; | |
| 768 | 811 | figureOutVersion(act); | 
| 769 | 812 |  | 
| 770 | 813 | Thread thread = new Thread() | 
| 771 | 814 |       {
 | 
| 772 | 815 | public void run() | 
| 773 | 816 |         {
 | 
| 774 | downloadThread(); | |
| 817 |         downloadThread(receiver);
 | |
| 775 | 818 | } | 
| 776 | 819 | }; | 
| 777 | 820 |  | 
| ... | ... | |
| 780 | 823 |  | 
| 781 | 824 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 782 | 825 |  | 
| 783 |   public void submit(Receiver receiver, FragmentActivity act)
 | |
| 826 |   public void submit(ScoresReceiver receiver, final FragmentActivity act)
 | |
| 784 | 827 |     {
 | 
| 785 | 828 | initializeStatics(); | 
| 786 | mReceiver = receiver; | |
| 787 | 829 | figureOutVersion(act); | 
| 788 | 830 |  | 
| 789 | 831 | Thread thread = new Thread() | 
| 790 | 832 |       {
 | 
| 791 | 833 | public void run() | 
| 792 | 834 |         {
 | 
| 793 | submitThread(); | |
| 835 |         submitThread(receiver);
 | |
| 794 | 836 | } | 
| 795 | 837 | }; | 
| 796 | 838 |  | 
| ... | ... | |
| 817 | 859 |  | 
| 818 | 860 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 819 | 861 |  | 
| 820 | public void suspicious(String suspicious) | |
| 862 |   public void suspicious(final String suspicious)
 | |
| 821 | 863 |     {
 | 
| 822 | 864 | initializeStatics(); | 
| 823 | mSuspicious = suspicious; | |
| 824 | 865 |  | 
| 825 | 866 | Thread thread = new Thread() | 
| 826 | 867 |       {
 | 
| 827 | 868 | public void run() | 
| 828 | 869 |         {
 | 
| 829 | suspiciousThread(); | |
| 870 |         suspiciousThread(suspicious);
 | |
| 830 | 871 | } | 
| 831 | 872 | }; | 
| 832 | 873 |  | 
| ... | ... | |
| 852 | 893 |  | 
| 853 | 894 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 854 | 895 |  | 
| 855 | public void downloadIcons(Updatee updatee) | |
| 896 | public void downloadIcons(final IconReceiver receiver) | |
| 897 |     {
 | |
| 898 | initializeStatics(); | |
| 899 |  | |
| 900 | Thread thread = new Thread() | |
| 901 |       {
 | |
| 902 | public void run() | |
| 903 |         {
 | |
| 904 | iconThread(receiver); | |
| 905 | } | |
| 906 | }; | |
| 907 |  | |
| 908 | thread.start(); | |
| 909 | } | |
| 910 |  | |
| 911 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 912 |  | |
| 913 | public void downloadJSON(final RubikUpdates.UpdateInfo info, final Downloadee downloadee) | |
| 856 | 914 |     {
 | 
| 857 | 915 | initializeStatics(); | 
| 858 | mUpdatee = updatee; | |
| 859 | 916 |  | 
| 860 | 917 | Thread thread = new Thread() | 
| 861 | 918 |       {
 | 
| 862 | 919 | public void run() | 
| 863 | 920 |         {
 | 
| 864 |         iconThread();
 | |
| 921 |         jsonThread(info,downloadee);
 | |
| 865 | 922 | } | 
| 866 | 923 | }; | 
| 867 | 924 |  | 
| src/main/java/org/distorted/network/RubikUpdates.java | ||
|---|---|---|
| 19 | 19 |  | 
| 20 | 20 | package org.distorted.network; | 
| 21 | 21 |  | 
| 22 | import java.io.InputStream; | |
| 22 | 23 | import java.util.ArrayList; | 
| 23 | 24 | import android.graphics.Bitmap; | 
| 24 | 25 | import org.distorted.objects.RubikObjectList; | 
| ... | ... | |
| 39 | 40 | public final boolean mUpdateObject; | 
| 40 | 41 | public final boolean mUpdateExtras; | 
| 41 | 42 | public Bitmap mIcon; | 
| 43 | public InputStream mObjectStream; | |
| 44 | public InputStream mExtrasStream; | |
| 42 | 45 |  | 
| 43 | 46 | public UpdateInfo(String shortName, String longName, String description, int objectMinor, | 
| 44 | 47 | int extrasMinor, int percent, int iconPresent, boolean updateO, boolean updateE) | 
| ... | ... | |
| 237 | 240 | return info!=null ? mUrl + info.mObjectShortName + ".png" : null; | 
| 238 | 241 | } | 
| 239 | 242 |  | 
| 243 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 244 |  | |
| 245 | public String getURL() | |
| 246 |     {
 | |
| 247 | return mUrl; | |
| 248 | } | |
| 249 |  | |
| 240 | 250 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 
| 241 | 251 |  | 
| 242 | 252 | public void setCompletedIcon(int ordinal, Bitmap icon) | 
| src/main/java/org/distorted/screens/RubikScreenPlay.java | ||
|---|---|---|
| 25 | 25 | import android.content.Context; | 
| 26 | 26 | import android.content.SharedPreferences; | 
| 27 | 27 | import android.content.res.Resources; | 
| 28 | import android.graphics.Bitmap; | |
| 29 | 28 | import android.graphics.drawable.BitmapDrawable; | 
| 30 | 29 | import android.os.Build; | 
| 31 | 30 | import android.os.Bundle; | 
| ... | ... | |
| 745 | 744 |     {
 | 
| 746 | 745 |     android.util.Log.e("D", "Screen: Error receiving update");
 | 
| 747 | 746 | } | 
| 748 |  | |
| 749 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
| 750 |  | |
| 751 | public void iconDownloaded(int ordinal, Bitmap bitmap) | |
| 752 |     {
 | |
| 753 | // empty | |
| 754 | } | |
| 755 | 747 | } | 
| src/main/res/values-de/strings.xml | ||
|---|---|---|
| 30 | 30 | <string name="new_name_try_again">Der von Ihnen ausgewählte Name %s ist bereits vergeben. Versuchen Sie es noch einmal:</string> | 
| 31 | 31 | <string name="downloading">Wird heruntergeladen…</string> | 
| 32 | 32 | <string name="submitting">Einreichen…</string> | 
| 33 | <string name="installing">Installieren…</string> | |
| 34 | <string name="networkError">Netzwerkfehler</string> | |
| 33 | 35 | <string name="view">Sehen</string> | 
| 34 | 36 | <string name="level_full">Volles Scramble</string> | 
| 35 | 37 |  | 
| src/main/res/values-es/strings.xml | ||
|---|---|---|
| 30 | 30 | <string name="new_name_try_again">El nombre que has elegido, %s, ya está en uso. Inténtalo de nuevo:</string> | 
| 31 | 31 | <string name="downloading">Descargando…</string> | 
| 32 | 32 | <string name="submitting">Enviando…</string> | 
| 33 | <string name="installing">Instalando…</string> | |
| 34 | <string name="networkError">Error de red</string> | |
| 33 | 35 | <string name="view">Ver</string> | 
| 34 | 36 | <string name="level_full">Revuelto Completo</string> | 
| 35 | 37 |  | 
| src/main/res/values-fr/strings.xml | ||
|---|---|---|
| 30 | 30 | <string name="new_name_try_again">Le nom que vous avez choisi, %s, est déjà pris. Réessayez :</string> | 
| 31 | 31 | <string name="downloading">Téléchargement…</string> | 
| 32 | 32 | <string name="submitting">Soumission…</string> | 
| 33 | <string name="installing">Installation…</string> | |
| 34 | <string name="networkError">Erreur réseau</string> | |
| 33 | 35 | <string name="view">Regarder</string> | 
| 34 | 36 | <string name="level_full">Brouillage Complet</string> | 
| 35 | 37 |  | 
| src/main/res/values-ja/strings.xml | ||
|---|---|---|
| 30 | 30 | <string name="new_name_try_again">選択した名前%sは既に使用されています。もう一度トライする:</string> | 
| 31 | 31 | <string name="downloading">ダウンロードしています…</string> | 
| 32 | 32 | <string name="submitting">送信しています…</string> | 
| 33 | <string name="installing">インストール…</string> | |
| 34 | <string name="networkError">ネットワークエラー</string> | |
| 33 | 35 | <string name="view">見る</string> | 
| 34 | 36 | <string name="level_full">フルスクランブル</string> | 
| 35 | 37 |  | 
| src/main/res/values-ko/strings.xml | ||
|---|---|---|
| 30 | 30 | <string name="new_name_try_again">선택한 이름 %s이(가) 이미 사용되었습니다. 다시 시도하십시오:</string> | 
| 31 | 31 | <string name="downloading">다운로드 중…</string> | 
| 32 | 32 | <string name="submitting">제출 중…</string> | 
| 33 | <string name="installing">설치 중…</string> | |
| 34 | <string name="networkError">네트워크 오류</string> | |
| 33 | 35 | <string name="view">보다</string> | 
| 34 | 36 | <string name="level_full">풀 스크램블</string> | 
| 35 | 37 |  | 
| src/main/res/values-pl/strings.xml | ||
|---|---|---|
| 30 | 30 | <string name="new_name_try_again">Imię które wybrałeś, %s, jest zajęte. Spróbuj jeszcze raz:</string> | 
| 31 | 31 | <string name="downloading">Ściąganie…</string> | 
| 32 | 32 | <string name="submitting">Przesyłanie…</string> | 
| 33 | <string name="installing">Instalowanie…</string> | |
| 34 | <string name="networkError">Błąd sieci</string> | |
| 33 | 35 | <string name="view">Zobacz</string> | 
| 34 | 36 | <string name="level_full">Pełne Pomieszanie</string> | 
| 35 | 37 |  | 
| src/main/res/values-ru/strings.xml | ||
|---|---|---|
| 30 | 30 | <string name="new_name_try_again">Выбранное вами имя %s уже занято. Попробуй еще раз:</string> | 
| 31 | 31 | <string name="downloading">Загрузка…</string> | 
| 32 | 32 | <string name="submitting">Добавляю…</string> | 
| 33 | <string name="installing">Установка…</string> | |
| 34 | <string name="networkError">Ошибка сети</string> | |
| 33 | 35 | <string name="view">Смотри</string> | 
| 34 | 36 | <string name="level_full">Полная Схватка</string> | 
| 35 | 37 |  | 
| src/main/res/values-zh-rCN/strings.xml | ||
|---|---|---|
| 30 | 30 | <string name="new_name_try_again">您选择的名称,%s,已被使用。请重试:</string> | 
| 31 | 31 | <string name="downloading">正在下载……</string> | 
| 32 | 32 | <string name="submitting">正在提交……</string> | 
| 33 | <string name="installing">安装…</string> | |
| 34 | <string name="networkError">網絡錯誤</string> | |
| 33 | 35 | <string name="view">看</string> | 
| 34 | 36 | <string name="level_full">级满</string> | 
| 35 | 37 |  | 
| src/main/res/values-zh-rTW/strings.xml | ||
|---|---|---|
| 30 | 30 | <string name="new_name_try_again">您選擇的名稱,%s,已被使用。請重試:</string> | 
| 31 | 31 | <string name="downloading">正在下載……</string> | 
| 32 | 32 | <string name="submitting">正在傳送……</string> | 
| 33 | <string name="installing">安裝…</string> | |
| 34 | <string name="networkError">網絡錯誤</string> | |
| 33 | 35 | <string name="view">看</string> | 
| 34 | 36 | <string name="level_full">級滿</string> | 
| 35 | 37 |  | 
| src/main/res/values/strings.xml | ||
|---|---|---|
| 31 | 31 | <string name="new_name_try_again">The name you have chosen, %s, is already taken. Try again:</string> | 
| 32 | 32 | <string name="downloading">Downloading…</string> | 
| 33 | 33 | <string name="submitting">Submitting…</string> | 
| 34 | <string name="installing">Installing…</string> | |
| 35 | <string name="networkError">Network Error</string> | |
| 34 | 36 | <string name="view">View</string> | 
| 35 | 37 | <string name="level_full">Full Scramble</string> | 
| 36 | 38 |  | 
Also available in: Unified diff
progress with the Updates: download the jsons.