Project

General

Profile

« Previous | Next » 

Revision 05f6d7bd

Added by Leszek Koltunski almost 2 years ago

  • ID 05f6d7bdfe0a0d9a3e75ec4893f596fe1d8a5497
  • Parent cf486b0d

Progress with new UI.

View differences:

src/main/java/org/distorted/dialogs/RubikDialogPlayPopup.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.dialogs;
21

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

  
31
import androidx.annotation.NonNull;
32
import androidx.appcompat.app.AlertDialog;
33
import androidx.appcompat.app.AppCompatDialogFragment;
34
import androidx.fragment.app.FragmentActivity;
35

  
36
import org.distorted.main.R;
37
import org.distorted.main.RubikActivity;
38

  
39
///////////////////////////////////////////////////////////////////////////////////////////////////
40

  
41
public class RubikDialogPlayPopup extends AppCompatDialogFragment
42
  {
43
  @NonNull
44
  @Override
45
  public Dialog onCreateDialog(Bundle savedInstanceState)
46
    {
47
    Bundle args = getArguments();
48
    int objectOrdinal;
49

  
50
    try
51
      {
52
      objectOrdinal = args.getInt("ordinal");
53
      }
54
    catch(Exception e)
55
      {
56
      objectOrdinal = 0;
57
      }
58

  
59
    FragmentActivity act = getActivity();
60
    LayoutInflater inflater = act.getLayoutInflater();
61
    AlertDialog.Builder builder = new AlertDialog.Builder(act);
62

  
63
    DisplayMetrics displaymetrics = new DisplayMetrics();
64
    act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
65
    final float titleSize= displaymetrics.widthPixels * RubikActivity.MENU_BIG_TEXT_SIZE;
66

  
67
    TextView tv = (TextView) inflater.inflate(R.layout.dialog_title, null);
68
    tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, titleSize);
69
    tv.setText(R.string.privacy_policy);
70
    builder.setCustomTitle(tv);
71

  
72
    final View view = inflater.inflate(R.layout.popup_play_new_ui, null);
73

  
74
    builder.setCancelable(true);
75
    builder.setView(view);
76

  
77
    final Dialog dialog = builder.create();
78
   // dialog.setCanceledOnTouchOutside(false);
79
    Window window = dialog.getWindow();
80

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

  
86
    return dialog;
87
    }
88
  }
src/main/java/org/distorted/objects/MainEntry.java
21 21

  
22 22
import android.app.Activity;
23 23
import android.graphics.drawable.Drawable;
24
import android.os.Bundle;
24 25
import android.widget.ImageButton;
25 26

  
27
import org.distorted.dialogs.RubikDialogPlayPopup;
28
import org.distorted.dialogs.RubikDialogScores;
26 29
import org.distorted.main.RubikActivity;
27 30

  
28 31
///////////////////////////////////////////////////////////////////////////////////////////////////
......
93 96
      {
94 97
      if( mObject!=null )
95 98
        {
96
        android.util.Log.e("D", "clicked on "+ mObject.getLowerName());
99
        Bundle bundle = new Bundle();
100
        bundle.putInt("ordinal", 0 );
101
        RubikDialogPlayPopup diag = new RubikDialogPlayPopup();
102
        diag.setArguments(bundle);
103
        diag.show(act.getSupportFragmentManager(), null);
97 104
        }
98 105
      else android.util.Log.e("D", "MainListEntry: object null!!");
99 106
      }
src/main/res/layout/popup_play_new_ui.xml
1
<?xml version="1.0" encoding="utf-8"?>
2
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
     android:layout_width="wrap_content"
4
     android:layout_height="wrap_content"
5
     android:orientation="horizontal"
6
     android:background="@color/dark_grey"
7
     android:baselineAligned="false"
8
     android:padding="5dp">
9

  
10
     <LinearLayout
11
          android:id="@+id/configLayout"
12
          android:layout_width="0dp"
13
          android:layout_height="wrap_content"
14
          android:layout_weight="1"
15
          android:orientation="vertical">
16

  
17
          <Button
18
             android:id="@+id/buttonConfig"
19
             android:layout_width="wrap_content"
20
             android:layout_height="wrap_content"/>
21
          <Button
22
             android:id="@+id/buttonTutorials"
23
             android:layout_width="wrap_content"
24
             android:layout_height="wrap_content"/>
25
          <Button
26
             android:id="@+id/buttonScores"
27
             android:layout_width="wrap_content"
28
             android:layout_height="wrap_content"/>
29
          <Button
30
             android:id="@+id/buttonPatterns"
31
             android:layout_width="wrap_content"
32
             android:layout_height="wrap_content"/>
33
          <Button
34
             android:id="@+id/buttonSolver"
35
             android:layout_width="wrap_content"
36
             android:layout_height="wrap_content"/>
37

  
38
     </LinearLayout>
39

  
40
     <ScrollView
41
          android:layout_width="0dp"
42
          android:layout_height="wrap_content"
43
          android:layout_weight="1">
44

  
45
          <LinearLayout
46
              android:id="@+id/playLayout"
47
              android:layout_width="wrap_content"
48
              android:layout_height="wrap_content"
49
              android:orientation="vertical">
50

  
51
              <Button
52
                android:id="@+id/buttonFreePlay"
53
                android:layout_width="wrap_content"
54
                android:layout_height="wrap_content"/>
55
              <Button
56
                android:id="@+id/buttonLevel1"
57
                android:layout_width="wrap_content"
58
                android:layout_height="wrap_content"/>
59
              <Button
60
                android:id="@+id/buttonLevel2"
61
                android:layout_width="wrap_content"
62
                android:layout_height="wrap_content"/>
63
              <Button
64
                android:id="@+id/buttonLevel3"
65
                android:layout_width="wrap_content"
66
                android:layout_height="wrap_content"/>
67
              <Button
68
                android:id="@+id/buttonLevel4"
69
                android:layout_width="wrap_content"
70
                android:layout_height="wrap_content"/>
71
              <Button
72
                android:id="@+id/buttonLevel5"
73
                android:layout_width="wrap_content"
74
                android:layout_height="wrap_content"/>
75
              <Button
76
                android:id="@+id/buttonLevel6"
77
                android:layout_width="wrap_content"
78
                android:layout_height="wrap_content"/>
79
              <Button
80
                android:id="@+id/buttonLevelFullScramble"
81
                android:layout_width="wrap_content"
82
                android:layout_height="wrap_content"/>
83

  
84
          </LinearLayout>
85
     </ScrollView>
86

  
87
</LinearLayout>

Also available in: Unified diff