Revision 9f006481
Added by Leszek Koltunski over 4 years ago
| src/main/java/org/distorted/dialogs/RubikDialogAbandon.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2020 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 |
|
|
| 32 |
import androidx.annotation.NonNull; |
|
| 33 |
import androidx.appcompat.app.AlertDialog; |
|
| 34 |
import androidx.appcompat.app.AppCompatDialogFragment; |
|
| 35 |
import androidx.fragment.app.FragmentActivity; |
|
| 36 |
|
|
| 37 |
import org.distorted.main.R; |
|
| 38 |
import org.distorted.main.RubikActivity; |
|
| 39 |
import org.distorted.screens.ScreenList; |
|
| 40 |
|
|
| 41 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 42 |
|
|
| 43 |
public class RubikDialogAbandon extends AppCompatDialogFragment |
|
| 44 |
{
|
|
| 45 |
@NonNull |
|
| 46 |
@Override |
|
| 47 |
public Dialog onCreateDialog(Bundle savedInstanceState) |
|
| 48 |
{
|
|
| 49 |
final RubikActivity ract = (RubikActivity)getContext(); |
|
| 50 |
|
|
| 51 |
FragmentActivity act = getActivity(); |
|
| 52 |
LayoutInflater inflater = act.getLayoutInflater(); |
|
| 53 |
AlertDialog.Builder builder = new AlertDialog.Builder(act); |
|
| 54 |
|
|
| 55 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
|
| 56 |
act.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); |
|
| 57 |
final float butSize = displaymetrics.widthPixels * RubikActivity.DIALOG_BUTTON_SIZE; |
|
| 58 |
|
|
| 59 |
final View view = inflater.inflate(R.layout.abandon_solve, null); |
|
| 60 |
builder.setView(view); |
|
| 61 |
builder.setCancelable(true); |
|
| 62 |
|
|
| 63 |
builder.setPositiveButton( R.string.yes, new DialogInterface.OnClickListener() |
|
| 64 |
{
|
|
| 65 |
@Override |
|
| 66 |
public void onClick(DialogInterface dialog, int which) |
|
| 67 |
{
|
|
| 68 |
ScreenList.goBack(ract); |
|
| 69 |
} |
|
| 70 |
}); |
|
| 71 |
|
|
| 72 |
builder.setNegativeButton( R.string.no, new DialogInterface.OnClickListener() |
|
| 73 |
{
|
|
| 74 |
@Override |
|
| 75 |
public void onClick(DialogInterface dialog, int which) |
|
| 76 |
{
|
|
| 77 |
// empty |
|
| 78 |
} |
|
| 79 |
}); |
|
| 80 |
|
|
| 81 |
final Dialog dialog = builder.create(); |
|
| 82 |
dialog.setCanceledOnTouchOutside(false); |
|
| 83 |
Window window = dialog.getWindow(); |
|
| 84 |
|
|
| 85 |
if( window!=null ) |
|
| 86 |
{
|
|
| 87 |
window.getDecorView().setSystemUiVisibility(RubikActivity.FLAGS); |
|
| 88 |
} |
|
| 89 |
|
|
| 90 |
dialog.setOnShowListener(new DialogInterface.OnShowListener() |
|
| 91 |
{
|
|
| 92 |
@Override |
|
| 93 |
public void onShow(DialogInterface dialog) |
|
| 94 |
{
|
|
| 95 |
Button btnPositive = ((AlertDialog)dialog).getButton(Dialog.BUTTON_POSITIVE); |
|
| 96 |
btnPositive.setTextSize(TypedValue.COMPLEX_UNIT_PX, butSize); |
|
| 97 |
Button btnNegative = ((AlertDialog)dialog).getButton(Dialog.BUTTON_NEGATIVE); |
|
| 98 |
btnNegative.setTextSize(TypedValue.COMPLEX_UNIT_PX, butSize); |
|
| 99 |
} |
|
| 100 |
}); |
|
| 101 |
|
|
| 102 |
return dialog; |
|
| 103 |
} |
|
| 104 |
} |
|
| src/main/java/org/distorted/helpers/MovesAndLockController.java | ||
|---|---|---|
| 232 | 232 |
|
| 233 | 233 |
public void addMove(TwistyActivity act, int axis, int row, int angle) |
| 234 | 234 |
{
|
| 235 |
if( mMoves.isEmpty()) changeBackMove(act,true); |
|
| 235 |
if( mMoves.isEmpty() ) changeBackMove(act,true);
|
|
| 236 | 236 |
mMoves.add(new Move(axis,row,angle)); |
| 237 | 237 |
} |
| 238 | 238 |
|
| ... | ... | |
| 252 | 252 |
changeBackMove(act,false); |
| 253 | 253 |
} |
| 254 | 254 |
|
| 255 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 256 |
|
|
| 257 |
public int getNumMoves() |
|
| 258 |
{
|
|
| 259 |
return mMoves.size(); |
|
| 260 |
} |
|
| 261 |
|
|
| 255 | 262 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 256 | 263 |
|
| 257 | 264 |
public void setupPrevButton(final TwistyActivity act, final float width) |
| src/main/java/org/distorted/screens/RubikScreenBase.java | ||
|---|---|---|
| 37 | 37 |
|
| 38 | 38 |
void createBottomPane(final RubikActivity act, float width, ImageButton button) |
| 39 | 39 |
{
|
| 40 |
mController.clearMoves(act); |
|
| 41 |
|
|
| 40 | 42 |
LinearLayout layoutBot = act.findViewById(R.id.lowerBar); |
| 41 | 43 |
layoutBot.removeAllViews(); |
| 42 | 44 |
|
| src/main/java/org/distorted/screens/RubikScreenSolving.java | ||
|---|---|---|
| 27 | 27 |
import android.widget.LinearLayout; |
| 28 | 28 |
import android.widget.TextView; |
| 29 | 29 |
|
| 30 |
import org.distorted.dialogs.RubikDialogAbandon; |
|
| 30 | 31 |
import org.distorted.helpers.TransparentImageButton; |
| 31 | 32 |
import org.distorted.main.R; |
| 32 | 33 |
import org.distorted.main.RubikActivity; |
| ... | ... | |
| 40 | 41 |
|
| 41 | 42 |
public class RubikScreenSolving extends RubikScreenBase |
| 42 | 43 |
{
|
| 44 |
private static final int MOVES_THRESHHOLD = 10; |
|
| 45 |
|
|
| 43 | 46 |
private TextView mTime; |
| 44 | 47 |
private Timer mTimer; |
| 45 | 48 |
private long mStartTime; |
| ... | ... | |
| 98 | 101 |
@Override |
| 99 | 102 |
public void onClick(View v) |
| 100 | 103 |
{
|
| 101 |
ScreenList.goBack(act); |
|
| 104 |
if( mController.getNumMoves() > MOVES_THRESHHOLD ) |
|
| 105 |
{
|
|
| 106 |
RubikDialogAbandon abaDiag = new RubikDialogAbandon(); |
|
| 107 |
abaDiag.show(act.getSupportFragmentManager(), null); |
|
| 108 |
} |
|
| 109 |
else |
|
| 110 |
{
|
|
| 111 |
ScreenList.goBack(act); |
|
| 112 |
} |
|
| 102 | 113 |
} |
| 103 | 114 |
}); |
| 104 | 115 |
} |
| src/main/res/layout/abandon_solve.xml | ||
|---|---|---|
| 1 |
<?xml version="1.0" encoding="utf-8"?> |
|
| 2 |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
|
| 3 |
android:layout_width="fill_parent" |
|
| 4 |
android:layout_height="fill_parent" |
|
| 5 |
android:layout_marginLeft="10dp" |
|
| 6 |
android:layout_marginTop="0dp" |
|
| 7 |
android:layout_marginRight="10dp" |
|
| 8 |
android:background="@color/grey" |
|
| 9 |
android:gravity="center|fill_horizontal"> |
|
| 10 |
|
|
| 11 |
<TextView |
|
| 12 |
android:id="@+id/privacy_string" |
|
| 13 |
android:layout_width="match_parent" |
|
| 14 |
android:layout_height="match_parent" |
|
| 15 |
android:layout_marginLeft="10dp" |
|
| 16 |
android:layout_marginTop="10dp" |
|
| 17 |
android:layout_marginRight="10dp" |
|
| 18 |
android:layout_marginBottom="10dp" |
|
| 19 |
android:gravity="center" |
|
| 20 |
android:text="@string/abandon_solve" |
|
| 21 |
android:textSize="24sp" /> |
|
| 22 |
</LinearLayout> |
|
| src/main/res/values-de/strings.xml | ||
|---|---|---|
| 39 | 39 |
<string name="solver">3x3x3 Löser</string> |
| 40 | 40 |
<string name="tutorials">Lernprogrammen</string> |
| 41 | 41 |
<string name="about">Über die App</string> |
| 42 |
<string name="abandon_solve">Gib auf</string> |
|
| 42 | 43 |
|
| 43 | 44 |
<string name="credits1">Open Source App, die mit der Distorted Graphics Library entwickelt wurde. Lizenziert unter <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">GPL Version 2</a> oder wie gewünscht einer späteren Version.</string> |
| 44 | 45 |
<string name="credits2">Hübsche Muster von Walter Randelshofer. Sehen Sie <a href="http://www.randelshofer.ch">http://www.randelshofer.ch</a></string> |
| src/main/res/values-es/strings.xml | ||
|---|---|---|
| 39 | 39 |
<string name="solver">Solucionador</string> |
| 40 | 40 |
<string name="tutorials">Tutoriales</string> |
| 41 | 41 |
<string name="about">Acerca de</string> |
| 42 |
<string name="abandon_solve">Abandonar</string> |
|
| 42 | 43 |
|
| 43 | 44 |
<string name="credits1">Aplicación de código abierto desarrollada con la biblioteca de gráficos de Distorted. Con licencia <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">GPL versión 2</a> o, a tu elección, cualquier versión posterior.</string> |
| 44 | 45 |
<string name="credits2">Pretty Patterns por Walter Randelshofer. Mira <a href="http://www.randelshofer.ch">http://www.randelshofer.ch</a></string> |
| src/main/res/values-fr/strings.xml | ||
|---|---|---|
| 39 | 39 |
<string name="solver">Solutionneur</string> |
| 40 | 40 |
<string name="tutorials">Tutoriels</string> |
| 41 | 41 |
<string name="about">À propos de</string> |
| 42 |
<string name="abandon_solve">Abandonner</string> |
|
| 42 | 43 |
|
| 43 | 44 |
<string name="credits1">Appli Open Source développée à l\'aide de la bibliothèque graphique Distorted. Sous licence <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">GPL version 2</a> ou - à votre choix - toute version ultérieure.</string> |
| 44 | 45 |
<string name="credits2">Pretty Patterns par Walter Randelshofer. Voir <a href="http://www.randelshofer.ch">http://www.randelshofer.ch</a></string> |
| src/main/res/values-ja/strings.xml | ||
|---|---|---|
| 39 | 39 |
<string name="solver">3x3x3 ソルバー</string> |
| 40 | 40 |
<string name="tutorials">チュートリアル</string> |
| 41 | 41 |
<string name="about">アプリについて</string> |
| 42 |
<string name="abandon_solve">あきらめる</string> |
|
| 42 | 43 |
|
| 43 | 44 |
<string name="credits1">ディストートグラフィックのライブラリを使用して開発されたオープンソースアプリ。<a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">GPL バージョン 2</a>でライセンスされているか、または-オプション-それ以降のすべてのバージョン。</string> |
| 44 | 45 |
<string name="credits2">Pretty Patterns 沿って Walter Randelshofer. 見る <a href="http://www.randelshofer.ch">http://www.randelshofer.ch</a></string> |
| src/main/res/values-ko/strings.xml | ||
|---|---|---|
| 39 | 39 |
<string name="solver">3x3x3 해결사</string> |
| 40 | 40 |
<string name="tutorials">튜토리얼</string> |
| 41 | 41 |
<string name="about">정보</string> |
| 42 |
<string name="abandon_solve">포기</string> |
|
| 42 | 43 |
|
| 43 | 44 |
<string name="credits1">왜곡된 그래픽 라이브러리를 사용하여 개발된 오픈 소스 앱. <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">GPL 버전 2</a> 또는 귀하의 선택에 따라 최신 버전으로 라이센스가 부여됩니다.</string> |
| 44 | 45 |
<string name="credits2">Pretty Patterns 으로 Walter Randelshofer. 보다 <a href="http://www.randelshofer.ch">http://www.randelshofer.ch</a></string> |
| src/main/res/values-pl/strings.xml | ||
|---|---|---|
| 39 | 39 |
<string name="solver">Rozwiązywacz</string> |
| 40 | 40 |
<string name="tutorials">Tutoriale</string> |
| 41 | 41 |
<string name="about">O aplikacji</string> |
| 42 |
<string name="abandon_solve">Zrezygnuj</string> |
|
| 42 | 43 |
|
| 43 | 44 |
<string name="credits1">Aplikacja open-source napisana wykorzystując bibliotekę Distorted. Licencja: <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">GPL wersja 2</a> albo jakakolwiek poźniejsza.</string> |
| 44 | 45 |
<string name="credits2">Piękne Wzory Waltera Randelshofera. Zobacz <a href="http://www.randelshofer.ch">http://www.randelshofer.ch</a></string> |
| src/main/res/values-ru/strings.xml | ||
|---|---|---|
| 39 | 39 |
<string name="solver">Решебник 3х3х3</string> |
| 40 | 40 |
<string name="tutorials">Учебники</string> |
| 41 | 41 |
<string name="about">О нас</string> |
| 42 |
<string name="abandon_solve">Сдаться</string> |
|
| 42 | 43 |
|
| 43 | 44 |
<string name="credits1">Приложение с открытым исходным кодом, разработанное с использованием библиотеки графики Искажений. Лицензируется согласно <a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">версии 2 GPL</a> или любой более поздней версии по вашему выбору.</string> |
| 44 | 45 |
<string name="credits2">Pretty Patterns по Walter Randelshofer. Смотри <a href="http://www.randelshofer.ch">http://www.randelshofer.ch</a></string> |
| src/main/res/values-zh-rCN/strings.xml | ||
|---|---|---|
| 39 | 39 |
<string name="solver">3x3x3求解器</string> |
| 40 | 40 |
<string name="tutorials">讲解</string> |
| 41 | 41 |
<string name="about">关于</string> |
| 42 |
<string name="abandon_solve">放弃</string> |
|
| 42 | 43 |
|
| 43 | 44 |
<string name="credits1">此应用程式原始码开发使用Distorted图型库。根据<a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">通用公共许可版本2</a>或者任何更新版本(根据您的选择)进行许可。</string> |
| 44 | 45 |
<string name="credits2">Pretty Patterns by Werner Randelshofer. 請看 <a href="http://www.randelshofer.ch">http://www.randelshofer.ch</a></string> |
| src/main/res/values-zh-rTW/strings.xml | ||
|---|---|---|
| 39 | 39 |
<string name="solver">3x3x3求解器</string> |
| 40 | 40 |
<string name="tutorials">講解</string> |
| 41 | 41 |
<string name="about">關於</string> |
| 42 |
<string name="abandon_solve">放棄</string> |
|
| 42 | 43 |
|
| 43 | 44 |
<string name="credits1">此應用程式原始碼開發使用Distorted圖型庫。根據<a href="https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html">通用公共許可版本2</a>或者任何更新版本(根據您的選擇)進行許可。</string> |
| 44 | 45 |
<string name="credits2">Pretty Patterns by Werner Randelshofer. 請看 <a href="http://www.randelshofer.ch">http://www.randelshofer.ch</a></string> |
| src/main/res/values/strings.xml | ||
|---|---|---|
| 50 | 50 |
<string name="privacy_policy_text" translatable="false">Please see and accept our <a href="https://distorted.org/redmine/projects/magic-cube/wiki/Privacy_policy">Privacy Policy</a></string> |
| 51 | 51 |
<string name="accept" translatable="false">Accept</string> |
| 52 | 52 |
<string name="decline" translatable="false">Decline</string> |
| 53 |
<string name="abandon_solve">Give up</string> |
|
| 53 | 54 |
|
| 54 | 55 |
<string name="opengl_error" translatable="false">Error</string> |
| 55 | 56 |
<string name="opengl_error_text" translatable="false">This device does not support OpenGL 3.0</string> |
Also available in: Unified diff
Add a 'give up' dialog - if one made at least 10 moves when solving and presses a 'back' button, one needs to confirm.