Project

General

Profile

« Previous | Next » 

Revision 5560eea9

Added by Leszek Koltunski over 5 years ago

Progress with UI.

View differences:

src/main/java/org/distorted/magic/RubikAbout.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Distorted.                                                               //
5
//                                                                                               //
6
// Distorted 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
// Distorted 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 Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

  
20
package org.distorted.magic;
21

  
22
import android.app.Dialog;
23
import android.content.DialogInterface;
24
import android.os.Bundle;
25
import android.support.annotation.NonNull;
26
import android.support.v4.app.FragmentActivity;
27
import android.support.v7.app.AlertDialog;
28
import android.support.v7.app.AppCompatDialogFragment;
29
import android.view.LayoutInflater;
30
import android.view.View;
31

  
32
///////////////////////////////////////////////////////////////////////////////////////////////////
33

  
34
public class RubikAbout extends AppCompatDialogFragment
35
  {
36
  @NonNull
37
  @Override
38
  public Dialog onCreateDialog(Bundle savedInstanceState)
39
    {
40
    FragmentActivity act = getActivity();
41
    AlertDialog.Builder builder = new AlertDialog.Builder(act);
42

  
43
    builder.setTitle(R.string.app_version);
44
    builder.setIcon(R.drawable.button3);
45
    builder.setCancelable(false);
46
    builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener()
47
      {
48
      @Override
49
      public void onClick(DialogInterface dialog, int which)
50
        {
51

  
52
        }
53
      });
54

  
55
    LayoutInflater inflater = act.getLayoutInflater();
56
    final View view = inflater.inflate(R.layout.about, null);
57
    builder.setView(view);
58

  
59
    return builder.create();
60
    }
61
  }
src/main/java/org/distorted/magic/RubikActivity.java
121 121

  
122 122
///////////////////////////////////////////////////////////////////////////////////////////////////
123 123

  
124
    public void Credits(View v)
124
    public void About(View v)
125 125
      {
126
      RubikCredits credits = new RubikCredits();
127
      credits.show(getSupportFragmentManager(), null);
126
      RubikAbout about = new RubikAbout();
127
      about.show(getSupportFragmentManager(), null);
128 128
      }
129 129

  
130 130
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/magic/RubikCredits.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Distorted.                                                               //
5
//                                                                                               //
6
// Distorted 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
// Distorted 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 Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

  
20
package org.distorted.magic;
21

  
22
import android.app.Dialog;
23
import android.content.DialogInterface;
24
import android.os.Bundle;
25
import android.support.annotation.NonNull;
26
import android.support.v4.app.FragmentActivity;
27
import android.support.v7.app.AlertDialog;
28
import android.support.v7.app.AppCompatDialogFragment;
29
import android.view.LayoutInflater;
30
import android.view.View;
31

  
32
///////////////////////////////////////////////////////////////////////////////////////////////////
33

  
34
public class RubikCredits extends AppCompatDialogFragment
35
  {
36
  @NonNull
37
  @Override
38
  public Dialog onCreateDialog(Bundle savedInstanceState)
39
    {
40
    FragmentActivity act = getActivity();
41
    AlertDialog.Builder builder = new AlertDialog.Builder(act);
42

  
43
    builder.setTitle(R.string.app_name);
44
    builder.setIcon(R.drawable.logo);
45
    builder.setCancelable(false);
46
    builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener()
47
      {
48
      @Override
49
      public void onClick(DialogInterface dialog, int which)
50
        {
51

  
52
        }
53
      });
54

  
55
    LayoutInflater inflater = act.getLayoutInflater();
56
    final View view = inflater.inflate(R.layout.credits, null);
57
    builder.setView(view);
58

  
59
    return builder.create();
60
    }
61
  }
src/main/java/org/distorted/magic/RubikSettings.java
231 231
      switch (bar.getId())
232 232
        {
233 233
        case R.id.appearDuration   : mAppearPos   = progress;
234
                                     mAppearDuration.setText(RubikActivity.translateDuration(mAppearPos)+" ms");
234
                                     int appear_ms= RubikActivity.translateDuration(mAppearPos);
235
                                     mAppearDuration.setText(getString(R.string.ms_placeholder,appear_ms));
235 236
                                     break;
236 237
        case R.id.disappearDuration: mDisappearPos= progress;
237
                                     mDisappearDuration.setText(RubikActivity.translateDuration(mDisappearPos)+" ms");
238
                                     int disappear_ms= RubikActivity.translateDuration(mDisappearPos);
239
                                     mDisappearDuration.setText(getString(R.string.ms_placeholder,disappear_ms));
238 240
                                     break;
239 241
        }
240 242
      }
src/main/res/layout/about.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

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

  
19
        <TextView
20
            android:layout_width="match_parent"
21
            android:layout_height="fill_parent"
22
            android:layout_weight="0.40"
23
            android:layout_marginTop="10dp"
24
            android:layout_marginLeft="10dp"
25
            android:layout_marginRight="10dp"
26
            android:layout_marginBottom="10dp"
27
            android:text="@string/credits1"/>
28

  
29
        <TextView
30
            android:layout_width="match_parent"
31
            android:layout_height="fill_parent"
32
            android:layout_weight="0.60"
33
            android:layout_marginBottom="10dp"
34
            android:layout_marginTop="10dp"
35
            android:layout_marginLeft="10dp"
36
            android:layout_marginRight="10dp"
37
            android:linksClickable="true"
38
            android:autoLink="web"
39
            android:text="@string/credits2"/>
40

  
41
    </LinearLayout>
42

  
43
</LinearLayout>
src/main/res/layout/credits.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

  
9
    <LinearLayout
10
        android:layout_width="fill_parent"
11
        android:layout_height="fill_parent"
12
        android:gravity="center|fill_horizontal"
13
        android:orientation="vertical">
14

  
15
        <TextView
16
            android:id="@+id/textView1"
17
            android:layout_width="match_parent"
18
            android:layout_height="fill_parent"
19
            android:layout_weight="0.33"
20
            android:layout_marginBottom="10dp"
21
            android:layout_marginTop="50dp"
22
            android:layout_marginLeft="20dp"
23
            android:layout_marginRight="20dp"
24
            android:text="@string/credits1"/>
25

  
26
        <TextView
27
            android:id="@+id/textView2"
28
            android:layout_width="match_parent"
29
            android:layout_height="fill_parent"
30
            android:layout_weight="0.33"
31
            android:layout_marginBottom="10dp"
32
            android:layout_marginTop="10dp"
33
            android:layout_marginLeft="20dp"
34
            android:layout_marginRight="20dp"
35
            android:text="@string/credits2"/>
36

  
37
        <TextView
38
            android:id="@+id/textView3"
39
            android:layout_width="match_parent"
40
            android:layout_height="fill_parent"
41
            android:layout_weight="0.33"
42
            android:layout_marginBottom="20dp"
43
            android:layout_marginTop="10dp"
44
            android:layout_marginLeft="20dp"
45
            android:layout_marginRight="20dp"
46
            android:text="@string/credits3"/>
47

  
48
    </LinearLayout>
49

  
50
</LinearLayout>
src/main/res/layout/main.xml
48 48
            android:src="@drawable/button4"/>
49 49

  
50 50
        <Button
51
            android:id="@+id/rubikCredits"
51
            android:id="@+id/rubikAbout"
52 52
            android:layout_width="wrap_content"
53 53
            android:layout_height="64dp"
54 54
            android:layout_weight="0.5"
55
            android:onClick="Credits"
55
            android:onClick="About"
56 56
            android:paddingLeft="5dp"
57 57
            android:paddingRight="5dp"
58
            android:text="@string/credits" />
58
            android:text="@string/about" />
59 59

  
60 60
    </LinearLayout>
61 61

  
src/main/res/layout/settings.xml
7 7

  
8 8
    <TextView
9 9
        android:layout_width="fill_parent"
10
        android:layout_height="64dp"
10
        android:layout_height="48dp"
11 11
        android:paddingStart="15dp"
12 12
        android:paddingEnd="15dp"
13 13
        android:gravity="start|center"
......
16 16

  
17 17
    <LinearLayout
18 18
        android:layout_width="fill_parent"
19
        android:layout_height="40dp"
20
        android:gravity="center|fill_horizontal"
21
        android:orientation="horizontal">
22

  
23
        <TextView
24
            android:layout_weight="0.25"
25
            android:layout_width="0dp"
26
            android:layout_height="fill_parent"
27
            android:paddingStart="5dp"
28
            android:paddingEnd="5dp"
29
            android:gravity="start|center"
30
            android:text="@string/duration"
31
            android:textAppearance="?android:attr/textAppearanceSmall" />
32

  
33
        <TextView
34
            android:id="@+id/disappearDurationText"
35
            android:layout_weight="0.25"
36
            android:layout_width="0dp"
37
            android:layout_height="fill_parent"
38
            android:paddingStart="5dp"
39
            android:paddingEnd="5dp"
40
            android:gravity="end|center"
41
            android:textAppearance="?android:attr/textAppearanceSmall" />
42

  
43
        <SeekBar
44
            android:id="@+id/disappearDuration"
45
            android:layout_weight="0.5"
46
            android:layout_width="0dp"
47
            android:layout_height="fill_parent"
48
            android:paddingLeft="10dp"
49
            android:paddingRight="10dp" />
50

  
51
    </LinearLayout>
52

  
53
    <LinearLayout
54
        android:layout_width="fill_parent"
55
        android:layout_height="40dp"
19
        android:layout_height="fill_parent"
20
        android:layout_weight="0.5"
56 21
        android:gravity="center|fill_horizontal"
57
        android:orientation="horizontal">
58

  
59
        <TextView
60
            android:layout_weight="0.5"
61
            android:layout_width="0dp"
62
            android:layout_height="fill_parent"
63
            android:paddingStart="5dp"
64
            android:paddingEnd="5dp"
65
            android:gravity="start|center"
66
            android:text="@string/type"
67
            android:textAppearance="?android:attr/textAppearanceSmall" />
68

  
69
        <Spinner
70
            android:id="@+id/disappearType"
71
            android:layout_weight="0.5"
72
            android:layout_width="0dp"
73
            android:layout_height="fill_parent"
74
            android:textAlignment="center"
75
            android:paddingLeft="10dp"
76
            android:paddingRight="10dp" />
77

  
22
        android:layout_marginLeft="10dp"
23
        android:layout_marginRight="10dp"
24
        android:background="@color/grey"
25
        android:orientation="vertical">
26

  
27
        <LinearLayout
28
            android:layout_width="fill_parent"
29
            android:layout_height="36dp"
30
            android:gravity="center|fill_horizontal"
31
            android:orientation="horizontal">
32

  
33
            <TextView
34
                android:layout_weight="0.2"
35
                android:layout_width="0dp"
36
                android:layout_height="fill_parent"
37
                android:paddingStart="5dp"
38
                android:paddingEnd="5dp"
39
                android:gravity="start|center"
40
                android:text="@string/duration"
41
                android:textAppearance="?android:attr/textAppearanceSmall" />
42

  
43
            <TextView
44
                android:id="@+id/disappearDurationText"
45
                android:layout_weight="0.2"
46
                android:layout_width="0dp"
47
                android:layout_height="fill_parent"
48
                android:paddingStart="5dp"
49
                android:paddingEnd="5dp"
50
                android:gravity="end|center"
51
                android:textAppearance="?android:attr/textAppearanceSmall" />
52

  
53
            <SeekBar
54
                android:id="@+id/disappearDuration"
55
                android:layout_weight="0.6"
56
                android:layout_width="0dp"
57
                android:layout_height="fill_parent"
58
                android:paddingLeft="10dp"
59
                android:paddingRight="10dp" />
60

  
61
        </LinearLayout>
62

  
63
        <LinearLayout
64
            android:layout_width="fill_parent"
65
            android:layout_height="36dp"
66
            android:gravity="center|fill_horizontal"
67
            android:orientation="horizontal">
68

  
69
            <TextView
70
                android:layout_weight="0.4"
71
                android:layout_width="0dp"
72
                android:layout_height="fill_parent"
73
                android:paddingStart="5dp"
74
                android:paddingEnd="5dp"
75
                android:gravity="start|center"
76
                android:text="@string/type"
77
                android:textAppearance="?android:attr/textAppearanceSmall" />
78

  
79
            <Spinner
80
                android:id="@+id/disappearType"
81
                android:layout_weight="0.6"
82
                android:layout_width="0dp"
83
                android:layout_height="fill_parent"
84
                android:textAlignment="center"
85
                android:paddingLeft="10dp"
86
                android:paddingRight="10dp" />
87

  
88
        </LinearLayout>
78 89
    </LinearLayout>
79 90

  
80 91
    <TextView
......
88 99

  
89 100
    <LinearLayout
90 101
        android:layout_width="fill_parent"
91
        android:layout_height="40dp"
102
        android:layout_height="fill_parent"
103
        android:layout_weight="0.5"
92 104
        android:gravity="center|fill_horizontal"
93
        android:orientation="horizontal">
94

  
95
        <TextView
96
            android:layout_weight="0.25"
97
            android:layout_width="0dp"
98
            android:layout_height="fill_parent"
99
            android:paddingStart="5dp"
100
            android:paddingEnd="5dp"
101
            android:gravity="start|center"
102
            android:text="@string/duration"
103
            android:textAppearance="?android:attr/textAppearanceSmall" />
104

  
105
        <TextView
106
            android:id="@+id/appearDurationText"
107
            android:layout_weight="0.25"
108
            android:layout_width="0dp"
109
            android:layout_height="fill_parent"
110
            android:paddingStart="5dp"
111
            android:paddingEnd="5dp"
112
            android:gravity="end|center"
113
            android:textAppearance="?android:attr/textAppearanceSmall" />
114

  
115
        <SeekBar
116
            android:id="@+id/appearDuration"
117
            android:layout_weight="0.5"
118
            android:layout_width="0dp"
119
            android:layout_height="fill_parent"
120
            android:paddingLeft="10dp"
121
            android:paddingRight="10dp" />
122

  
123
    </LinearLayout>
124

  
125
    <LinearLayout
126
        android:layout_width="fill_parent"
127
        android:layout_height="40dp"
128
        android:gravity="center|fill_horizontal"
129
        android:orientation="horizontal">
130

  
131
        <TextView
132
            android:layout_weight="0.5"
133
            android:layout_width="0dp"
134
            android:layout_height="fill_parent"
135
            android:paddingStart="5dp"
136
            android:paddingEnd="5dp"
137
            android:gravity="start|center"
138
            android:text="@string/type"
139
            android:textAppearance="?android:attr/textAppearanceSmall" />
140

  
141
        <Spinner
142
            android:id="@+id/appearType"
143
            android:layout_weight="0.5"
144
            android:layout_width="0dp"
145
            android:layout_height="fill_parent"
146
            android:textAlignment="center"
147
            android:paddingLeft="10dp"
148
            android:paddingRight="10dp" />
149

  
105
        android:layout_marginLeft="10dp"
106
        android:layout_marginRight="10dp"
107
        android:layout_marginBottom="10dp"
108
        android:background="@color/grey"
109
        android:orientation="vertical">
110

  
111
        <LinearLayout
112
            android:layout_width="fill_parent"
113
            android:layout_height="36dp"
114
            android:gravity="center|fill_horizontal"
115
            android:orientation="horizontal">
116

  
117
            <TextView
118
                android:layout_weight="0.2"
119
                android:layout_width="0dp"
120
                android:layout_height="fill_parent"
121
                android:paddingStart="5dp"
122
                android:paddingEnd="5dp"
123
                android:gravity="start|center"
124
                android:text="@string/duration"
125
                android:textAppearance="?android:attr/textAppearanceSmall" />
126

  
127
            <TextView
128
                android:id="@+id/appearDurationText"
129
                android:layout_weight="0.2"
130
                android:layout_width="0dp"
131
                android:layout_height="fill_parent"
132
                android:paddingStart="5dp"
133
                android:paddingEnd="5dp"
134
                android:gravity="end|center"
135
                android:textAppearance="?android:attr/textAppearanceSmall" />
136

  
137
            <SeekBar
138
                android:id="@+id/appearDuration"
139
                android:layout_weight="0.6"
140
                android:layout_width="0dp"
141
                android:layout_height="fill_parent"
142
                android:paddingLeft="10dp"
143
                android:paddingRight="10dp" />
144

  
145
        </LinearLayout>
146

  
147
        <LinearLayout
148
            android:layout_width="fill_parent"
149
            android:layout_height="36dp"
150
            android:gravity="center|fill_horizontal"
151
            android:orientation="horizontal">
152

  
153
            <TextView
154
                android:layout_weight="0.4"
155
                android:layout_width="0dp"
156
                android:layout_height="fill_parent"
157
                android:paddingStart="5dp"
158
                android:paddingEnd="5dp"
159
                android:gravity="start|center"
160
                android:text="@string/type"
161
                android:textAppearance="?android:attr/textAppearanceSmall" />
162

  
163
            <Spinner
164
                android:id="@+id/appearType"
165
                android:layout_weight="0.6"
166
                android:layout_width="0dp"
167
                android:layout_height="fill_parent"
168
                android:textAlignment="center"
169
                android:paddingLeft="10dp"
170
                android:paddingRight="10dp" />
171

  
172
        </LinearLayout>
150 173
    </LinearLayout>
151 174

  
152 175
</LinearLayout>
src/main/res/values/colors.xml
4 4
    <color name="colorPrimaryDark">#00574B</color>
5 5
    <color name="colorAccent">#D81B60</color>
6 6
    <color name="red">#ffff0000</color>
7
    <color name="grey">#ff333333</color>
7 8
</resources>
src/main/res/values/strings.xml
1 1
<resources>
2 2
    <string name="app_name">Magic Cube</string>
3
    <string name="app_version">Magic Cube v1.0.0</string>
3 4
    <string name="distorted">DISTORTED</string>
4 5
    <string name="scramble">Scramble</string>
5 6
    <string name="solve">Solve</string>
6 7
    <string name="settings">Settings</string>
7
    <string name="credits">Credits</string>
8
    <string name="about">About</string>
8 9
    <string name="save">SAVE</string>
9 10
    <string name="ok">OK</string>
10
    <string name="appear">Appear Effects</string>
11
    <string name="disappear">Disappear Effects</string>
11
    <string name="appear">New Cube Appear Effect:</string>
12
    <string name="disappear">Old Cube Disappear Effect:</string>
12 13
    <string name="duration">Duration:</string>
13 14
    <string name="type">Type:</string>
14 15
    <string name="credits1">Open Source app developed using the Distorted graphics library. </string>
15
    <string name="credits2">Code, tutorials, how to write your own graphics effect: http://www.distorted.org/cube</string>
16
    <string name="credits3">Distorted.org 2019</string>
16
    <string name="credits2">Code, tutorials, learn how to write your own graphics effect: <a href="http://www.distorted.org/cube">Distorted.org</a></string>
17
    <string name="ms_placeholder">%1$d ms</string>
17 18
</resources>

Also available in: Unified diff