Project

General

Profile

« Previous | Next » 

Revision 1db19441

Added by Leszek Koltunski over 2 years ago

BandagedPlay: dialog

View differences:

src/main/java/org/distorted/bandaged/BandagedPlayScreen.java
26 26
import android.view.View;
27 27
import android.widget.LinearLayout;
28 28

  
29
import org.distorted.dialogs.RubikDialogBandagedSettings;
29 30
import org.distorted.helpers.LockController;
30 31
import org.distorted.helpers.MovesController;
31 32
import org.distorted.helpers.TransparentImageButton;
......
41 42
  public static final int ANIMATION_ON  = 0;
42 43
  public static final int ANIMATION_OFF = 1;
43 44

  
44
  private static final int NUM_SCRAMBLES = 2;
45
  private static final int NUM_SCRAMBLES = 30;
45 46

  
46
  private TransparentImageButton mBackButton, mScrambleButton, mSolveButton;
47
  private TransparentImageButton mBackButton, mScrambleButton, mSolveButton, mSettingsButton;
47 48
  private final LockController mLockController;
48 49
  private final MovesController mMovesController;
49 50
  private String mKey;
......
84 85
      });
85 86
    }
86 87

  
88
///////////////////////////////////////////////////////////////////////////////////////////////////
89

  
90
  private void setupSettingsButton(final BandagedPlayActivity act)
91
    {
92
    int icon = BandagedPlayActivity.getDrawable(R.drawable.ui_small_settings,R.drawable.ui_medium_settings, R.drawable.ui_big_settings, R.drawable.ui_huge_settings);
93
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT);
94
    mSettingsButton = new TransparentImageButton(act, icon, TransparentImageButton.GRAVITY_MIDDLE, params);
95

  
96
    mSettingsButton.setOnClickListener( new View.OnClickListener()
97
      {
98
      @Override
99
      public void onClick(View v)
100
        {
101
        RubikDialogBandagedSettings setDiag = new RubikDialogBandagedSettings();
102
        setDiag.show(act.getSupportFragmentManager(), null);
103
        }
104
      });
105
    }
106

  
87 107
///////////////////////////////////////////////////////////////////////////////////////////////////
88 108

  
89 109
  private void setupSolveButton(final BandagedPlayActivity act)
......
182 202
    layoutLower.addView(layoutMid);
183 203
    layoutLower.addView(layoutRight);
184 204

  
185
    setupScrambleButton(act);
186 205
    setupSolveButton(act);
206
    setupSettingsButton(act);
207
    setupScrambleButton(act);
187 208

  
188 209
    LinearLayout layoutUpper = act.findViewById(R.id.upperBar);
189 210

  
......
195 216
    layoutRightU.setLayoutParams(paramsR);
196 217

  
197 218
    layoutLeftU.addView(mSolveButton);
219
    layoutMidU.addView(mSettingsButton);
198 220
    layoutRightU.addView(mScrambleButton);
199 221

  
200 222
    layoutUpper.removeAllViews();
src/main/java/org/distorted/dialogs/RubikDialogBandagedSettings.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 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.dialogs;
21

  
22
import android.app.Dialog;
23
import android.content.DialogInterface;
24
import android.os.Bundle;
25
import android.util.DisplayMetrics;
26
import android.util.TypedValue;
27
import android.view.LayoutInflater;
28
import android.view.View;
29
import android.view.Window;
30
import android.widget.Button;
31
import android.widget.TextView;
32

  
33
import androidx.annotation.NonNull;
34
import androidx.appcompat.app.AlertDialog;
35
import androidx.appcompat.app.AppCompatDialogFragment;
36
import androidx.fragment.app.FragmentActivity;
37

  
38
import org.distorted.main.R;
39
import org.distorted.main.RubikActivity;
40

  
41
///////////////////////////////////////////////////////////////////////////////////////////////////
42

  
43
public class RubikDialogBandagedSettings extends AppCompatDialogFragment
44
  {
45
  @NonNull
46
  @Override
47
  public Dialog onCreateDialog(Bundle savedInstanceState)
48
    {
49
    FragmentActivity act = getActivity();
50
    LayoutInflater inflater = act.getLayoutInflater();
51
    AlertDialog.Builder builder = new AlertDialog.Builder(act);
52

  
53
    DisplayMetrics displaymetrics = new DisplayMetrics();
54
    act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
55
    final float titleSize= displaymetrics.widthPixels * RubikActivity.MENU_BIG_TEXT_SIZE;
56
    final float okSize   = displaymetrics.widthPixels * RubikActivity.DIALOG_BUTTON_SIZE;
57
    final float textSize = displaymetrics.widthPixels * RubikActivity.MENU_SMALL_TEXT_SIZE;
58

  
59
    TextView tv = (TextView) inflater.inflate(R.layout.dialog_title, null);
60
    tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize);
61
    tv.setText(R.string.settings);
62
    builder.setCustomTitle(tv);
63

  
64
    builder.setCancelable(true);
65
    builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener()
66
      {
67
      @Override
68
      public void onClick(DialogInterface dialog, int which)
69
        {
70

  
71
        }
72
      });
73

  
74
    final View view = inflater.inflate(R.layout.dialog_settings, null);
75

  
76

  
77
    builder.setView(view);
78

  
79
    Dialog dialog = builder.create();
80
    dialog.setCanceledOnTouchOutside(false);
81
    Window window = dialog.getWindow();
82

  
83
    if( window!=null )
84
      {
85
      window.getDecorView().setSystemUiVisibility(RubikActivity.FLAGS);
86
      }
87

  
88
    dialog.setOnShowListener(new DialogInterface.OnShowListener()
89
      {
90
      @Override
91
      public void onShow(DialogInterface dialog)
92
        {
93
        Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE);
94
        btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, okSize);
95
        }
96
      });
97

  
98
    return dialog;
99
    }
100
  }
src/main/res/layout/dialog_settings.xml
1
<?xml version="1.0" encoding="utf-8"?>
2
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
    android:layout_width="match_parent"
4
    android:layout_height="match_parent"
5
    android:gravity="center_horizontal"
6
    android:orientation="vertical">
7

  
8
    <LinearLayout
9
        android:layout_width="fill_parent"
10
        android:layout_height="fill_parent"
11
        android:gravity="center|fill_horizontal"
12
        android:layout_marginLeft="10dp"
13
        android:layout_marginRight="10dp"
14
        android:layout_marginTop="0dp"
15
        android:background="@color/grey"
16
        android:orientation="vertical">
17

  
18
        <TextView
19
            android:id="@+id/solved_time"
20
            android:layout_width="match_parent"
21
            android:layout_height="match_parent"
22
            android:gravity="center"
23
            android:textSize="24sp"
24
            android:layout_marginTop="10dp"
25
            android:layout_marginLeft="10dp"
26
            android:layout_marginRight="10dp"
27
            android:layout_marginBottom="10dp"/>
28

  
29
    </LinearLayout>
30
</LinearLayout>
src/main/res/values-de/strings.xml
41 41
    <string name="save_object_really">Möchten Sie diesen Cube speichern?</string>
42 42
    <string name="delete_object">Löschen</string>
43 43
    <string name="delete_object_really">Möchten Sie diesen Cube löschen?</string>
44
    <string name="settings">Einstellungen</string>
44 45

  
45 46
    <string name="scores">Highscores</string>
46 47
    <string name="patterns">Hübsche Muster</string>
src/main/res/values-es/strings.xml
41 41
    <string name="save_object_really">¿Quieres guardar este Cubo?</string>
42 42
    <string name="delete_object">Borrar</string>
43 43
    <string name="delete_object_really">¿Quieres borrar este Cubo?</string>
44
    <string name="settings">Ajustes</string>
44 45

  
45 46
    <string name="scores">Leaderboard</string>
46 47
    <string name="patterns">Patrones</string>
src/main/res/values-fr/strings.xml
41 41
    <string name="save_object_really">Voulez-vous enregistrer ce Cube?</string>
42 42
    <string name="delete_object">Supprimer</string>
43 43
    <string name="delete_object_really">Voulez-vous supprimer ce Cube?</string>
44
    <string name="settings">Réglages</string>
44 45

  
45 46
    <string name="scores">Meilleurs scores</string>
46 47
    <string name="patterns">Jolis motifs</string>
src/main/res/values-ja/strings.xml
41 41
    <string name="save_object_really">このキューブを保存しますか?</string>
42 42
    <string name="delete_object">消す</string>
43 43
    <string name="delete_object_really">このキューブを削除しますか?</string>
44
    <string name="settings">設定</string>
44 45

  
45 46
    <string name="scores">ハイスコア</string>
46 47
    <string name="patterns">プリティパターン</string>
src/main/res/values-ko/strings.xml
41 41
    <string name="save_object_really">이 큐브를 저장하시겠습니까?</string>
42 42
    <string name="delete_object">삭제</string>
43 43
    <string name="delete_object_really">이 큐브를 삭제하시겠습니까?</string>
44
    <string name="settings">설정</string>
44 45

  
45 46
    <string name="scores">고득점</string>
46 47
    <string name="patterns">예쁜 패턴</string>
src/main/res/values-pl/strings.xml
41 41
    <string name="save_object_really">Chcesz zapisać tą kostkę?</string>
42 42
    <string name="delete_object">Usuń</string>
43 43
    <string name="delete_object_really">Chcesz usunąć tą kostkę?</string>
44
    <string name="settings">Ustawienia</string>
44 45

  
45 46
    <string name="scores">Lista najlepszych</string>
46 47
    <string name="patterns">Piękne Wzory</string>
src/main/res/values-ru/strings.xml
41 41
    <string name="save_object_really">Вы хотите сохранить этот куб?</string>
42 42
    <string name="delete_object">Удалить</string>
43 43
    <string name="delete_object_really">Вы хотите удалить этот куб?</string>
44
    <string name="settings">Настройки</string>
44 45

  
45 46
    <string name="scores">Высокие баллы</string>
46 47
    <string name="patterns">Красивые узоры</string>
src/main/res/values-zh-rCN/strings.xml
41 41
    <string name="save_object_really">你想保存这个多维数据集吗?</string>
42 42
    <string name="delete_object">删除</string>
43 43
    <string name="delete_object_really">你想删除这个立方体吗?</string>
44
    <string name="settings">设置</string>
44 45

  
45 46
    <string name="scores">高分</string>
46 47
    <string name="patterns">模式</string>
src/main/res/values-zh-rTW/strings.xml
41 41
    <string name="save_object_really">你想保存這個多維數據集嗎?</string>
42 42
    <string name="delete_object">刪除</string>
43 43
    <string name="delete_object_really">是否要刪除此多維數據集?</string>
44
    <string name="settings">設置</string>
44 45

  
45 46
    <string name="scores">高分</string>
46 47
    <string name="patterns">模式</string>
src/main/res/values/strings.xml
42 42
    <string name="save_object_really">Do you want to save this Cube?</string>
43 43
    <string name="delete_object">Delete</string>
44 44
    <string name="delete_object_really">Do you want to delete this Cube?</string>
45
    <string name="settings">Settings</string>
45 46

  
46 47
    <string name="scores">High Scores</string>
47 48
    <string name="patterns">Pretty Patterns</string>

Also available in: Unified diff