Project

General

Profile

« Previous | Next » 

Revision 35161021

Added by Leszek Koltunski almost 3 years ago

Beginnings of support for saving the downloaded JSONs in local data storage.

View differences:

src/main/java/org/distorted/dialogs/RubikDialogUpdateView.java
30 30
import android.widget.ProgressBar;
31 31
import android.widget.TextView;
32 32

  
33
import org.distorted.external.RubikFiles;
33 34
import org.distorted.main.R;
34 35
import org.distorted.external.RubikNetwork;
35 36
import org.distorted.external.RubikUpdates;
......
131 132
      {
132 133
      mBar.setProgress(50);
133 134
      mDescription.setText(R.string.installing);
135

  
136
      RubikFiles files = RubikFiles.getInstance();
137
      boolean oSuccess=true, eSuccess=true;
138

  
139
      if( mInfo.mObjectStream!=null )
140
        {
141
        String name = mInfo.mObjectShortName + "_object.json";
142
        oSuccess = files.saveFile(mInfo.mObjectStream, name);
143
        }
144

  
145
      if( mInfo.mExtrasStream!=null )
146
        {
147
        String name = mInfo.mObjectShortName + "_extras.json";
148
        eSuccess = files.saveFile(mInfo.mExtrasStream, name);
149
        }
150

  
151
      if( oSuccess )
152
        {
153
        mBar.setProgress(75);
154
        mDescription.setText(R.string.configuring);
155
        }
156
      else
157
        {
158
        mDescription.setTextColor(Color.parseColor("#ff0000"));
159
        mDescription.setText(R.string.saveError);
160
        }
134 161
      }
135 162
    }
136 163
  }
src/main/java/org/distorted/external/RubikFiles.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2022 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

  
20
package org.distorted.external;
21

  
22
import java.io.InputStream;
23

  
24
public class RubikFiles
25
  {
26
  private static RubikFiles mThis;
27

  
28
///////////////////////////////////////////////////////////////////////////////////////////////////
29

  
30
  private RubikFiles()
31
    {
32

  
33
    }
34

  
35
///////////////////////////////////////////////////////////////////////////////////////////////////
36
// PUBLIC API
37
///////////////////////////////////////////////////////////////////////////////////////////////////
38

  
39
  public static RubikFiles getInstance()
40
    {
41
    if( mThis==null ) mThis = new RubikFiles();
42
    return mThis;
43
    }
44

  
45
///////////////////////////////////////////////////////////////////////////////////////////////////
46

  
47
  public boolean saveFile(InputStream stream, String name)
48
    {
49
    return false;
50
    }
51
  }
src/main/java/org/distorted/external/RubikNetwork.java
795 795

  
796 796
  public static RubikNetwork getInstance()
797 797
    {
798
    if( mThis==null )
799
      {
800
      mThis = new RubikNetwork();
801
      }
802

  
798
    if( mThis==null ) mThis = new RubikNetwork();
803 799
    return mThis;
804 800
    }
805 801

  
src/main/res/values-de/strings.xml
31 31
    <string name="downloading">Wird heruntergeladen…</string>
32 32
    <string name="submitting">Einreichen…</string>
33 33
    <string name="installing">Installieren…</string>
34
    <string name="configuring">Konfigurieren…</string>
35
    <string name="saveError">Fehler beim Speichern der Datei</string>
34 36
    <string name="networkError">Netzwerkfehler</string>
35 37
    <string name="view">Sehen</string>
36 38
    <string name="level_full">Volles Scramble</string>
src/main/res/values-es/strings.xml
31 31
    <string name="downloading">Descargando…</string>
32 32
    <string name="submitting">Enviando…</string>
33 33
    <string name="installing">Instalando…</string>
34
    <string name="configuring">Configurando…</string>
35
    <string name="saveError">Error al guardar el archivo</string>
34 36
    <string name="networkError">Error de red</string>
35 37
    <string name="view">Ver</string>
36 38
    <string name="level_full">Revuelto Completo</string>
src/main/res/values-fr/strings.xml
31 31
    <string name="downloading">Téléchargement…</string>
32 32
    <string name="submitting">Soumission…</string>
33 33
    <string name="installing">Installation…</string>
34
    <string name="configuring">Configuration…</string>
35
    <string name="saveError">Échec de l\'enregistrement du fichier</string>
34 36
    <string name="networkError">Erreur réseau</string>
35 37
    <string name="view">Regarder</string>
36 38
    <string name="level_full">Brouillage Complet</string>
src/main/res/values-ja/strings.xml
31 31
    <string name="downloading">ダウンロードしています…</string>
32 32
    <string name="submitting">送信しています…</string>
33 33
    <string name="installing">インストール…</string>
34
    <string name="configuring">構成…</string>
35
    <string name="saveError">ファイルの保存に失敗しました</string>
34 36
    <string name="networkError">ネットワークエラー</string>
35 37
    <string name="view">見る</string>
36 38
    <string name="level_full">フルスクランブル</string>
src/main/res/values-ko/strings.xml
31 31
    <string name="downloading">다운로드 중…</string>
32 32
    <string name="submitting">제출 중…</string>
33 33
    <string name="installing">설치 중…</string>
34
    <string name="configuring">구성…</string>
35
    <string name="saveError">파일 저장 실패</string>
34 36
    <string name="networkError">네트워크 오류</string>
35 37
    <string name="view">보다</string>
36 38
    <string name="level_full">풀 스크램블</string>
src/main/res/values-pl/strings.xml
31 31
    <string name="downloading">Ściąganie…</string>
32 32
    <string name="submitting">Przesyłanie…</string>
33 33
    <string name="installing">Instalowanie…</string>
34
    <string name="configuring">Konfigurowanie…</string>
35
    <string name="saveError">Błąd zapisu pliku</string>
34 36
    <string name="networkError">Błąd sieci</string>
35 37
    <string name="view">Zobacz</string>
36 38
    <string name="level_full">Pełne Pomieszanie</string>
src/main/res/values-ru/strings.xml
31 31
    <string name="downloading">Загрузка…</string>
32 32
    <string name="submitting">Добавляю…</string>
33 33
    <string name="installing">Установка…</string>
34
    <string name="configuring">Настройка…</string>
35
    <string name="saveError">Не удалось сохранить файл</string>
34 36
    <string name="networkError">Ошибка сети</string>
35 37
    <string name="view">Смотри</string>
36 38
    <string name="level_full">Полная Схватка</string>
src/main/res/values-zh-rCN/strings.xml
31 31
    <string name="downloading">正在下载……</string>
32 32
    <string name="submitting">正在提交……</string>
33 33
    <string name="installing">安装…</string>
34
    <string name="configuring">配置…</string>
35
    <string name="saveError">保存文件失败</string>
34 36
    <string name="networkError">網絡錯誤</string>
35 37
    <string name="view">看</string>
36 38
    <string name="level_full">级满</string>
src/main/res/values-zh-rTW/strings.xml
31 31
    <string name="downloading">正在下載……</string>
32 32
    <string name="submitting">正在傳送……</string>
33 33
    <string name="installing">安裝…</string>
34
    <string name="configuring">配置…</string>
35
    <string name="saveError">保存文件失敗</string>
34 36
    <string name="networkError">網絡錯誤</string>
35 37
    <string name="view">看</string>
36 38
    <string name="level_full">級滿</string>
src/main/res/values/strings.xml
32 32
    <string name="downloading">Downloading…</string>
33 33
    <string name="submitting">Submitting…</string>
34 34
    <string name="installing">Installing…</string>
35
    <string name="configuring">Configuring…</string>
36
    <string name="saveError">Failed to save file</string>
35 37
    <string name="networkError">Network Error</string>
36 38
    <string name="view">View</string>
37 39
    <string name="level_full">Full Scramble</string>

Also available in: Unified diff