Revision 2d9fc972
Added by Leszek Koltunski over 5 years ago
| build.gradle | ||
|---|---|---|
| 15 | 15 |
applicationId "org.distorted.magic" |
| 16 | 16 |
minSdkVersion 21 |
| 17 | 17 |
targetSdkVersion 29 |
| 18 |
versionCode 7
|
|
| 19 |
versionName "1.2.0"
|
|
| 18 |
versionCode 8
|
|
| 19 |
versionName "1.2.1"
|
|
| 20 | 20 |
} |
| 21 | 21 |
|
| 22 | 22 |
buildTypes {
|
| src/main/java/org/distorted/dialogs/RubikDialogError.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.view.LayoutInflater; |
|
| 26 |
import android.view.View; |
|
| 27 |
import android.widget.TextView; |
|
| 28 |
|
|
| 29 |
import androidx.annotation.NonNull; |
|
| 30 |
import androidx.appcompat.app.AlertDialog; |
|
| 31 |
import androidx.appcompat.app.AppCompatDialogFragment; |
|
| 32 |
import androidx.fragment.app.FragmentActivity; |
|
| 33 |
|
|
| 34 |
import org.distorted.main.R; |
|
| 35 |
|
|
| 36 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 37 |
|
|
| 38 |
public class RubikDialogError extends AppCompatDialogFragment |
|
| 39 |
{
|
|
| 40 |
@NonNull |
|
| 41 |
@Override |
|
| 42 |
public Dialog onCreateDialog(Bundle savedInstanceState) |
|
| 43 |
{
|
|
| 44 |
FragmentActivity act = getActivity(); |
|
| 45 |
LayoutInflater inflater = act.getLayoutInflater(); |
|
| 46 |
AlertDialog.Builder builder = new AlertDialog.Builder(act); |
|
| 47 |
|
|
| 48 |
Bundle args = getArguments(); |
|
| 49 |
String error; |
|
| 50 |
|
|
| 51 |
try |
|
| 52 |
{
|
|
| 53 |
error = args.getString("error");
|
|
| 54 |
} |
|
| 55 |
catch(Exception e) |
|
| 56 |
{
|
|
| 57 |
error = "Error getting error"; |
|
| 58 |
} |
|
| 59 |
|
|
| 60 |
TextView tv = (TextView) inflater.inflate(R.layout.dialog_title, null); |
|
| 61 |
tv.setText(R.string.opengl_error); |
|
| 62 |
builder.setCustomTitle(tv); |
|
| 63 |
|
|
| 64 |
final View view = inflater.inflate(R.layout.dialog_error, null); |
|
| 65 |
TextView text = view.findViewById(R.id.error_string); |
|
| 66 |
text.setText(error); |
|
| 67 |
|
|
| 68 |
builder.setCancelable(true); |
|
| 69 |
|
|
| 70 |
builder.setPositiveButton( R.string.ok, new DialogInterface.OnClickListener() |
|
| 71 |
{
|
|
| 72 |
@Override |
|
| 73 |
public void onClick(DialogInterface dialog, int which) |
|
| 74 |
{
|
|
| 75 |
|
|
| 76 |
} |
|
| 77 |
}); |
|
| 78 |
|
|
| 79 |
builder.setView(view); |
|
| 80 |
|
|
| 81 |
final Dialog dialog = builder.create(); |
|
| 82 |
dialog.setCanceledOnTouchOutside(false); |
|
| 83 |
|
|
| 84 |
return dialog; |
|
| 85 |
} |
|
| 86 |
} |
|
| src/main/java/org/distorted/main/RubikActivity.java | ||
|---|---|---|
| 28 | 28 |
import com.google.firebase.analytics.FirebaseAnalytics; |
| 29 | 29 |
|
| 30 | 30 |
import org.distorted.dialogs.RubikDialogAbout; |
| 31 |
import org.distorted.dialogs.RubikDialogError; |
|
| 31 | 32 |
import org.distorted.dialogs.RubikDialogScores; |
| 32 | 33 |
import org.distorted.dialogs.RubikDialogEffects; |
| 33 | 34 |
import org.distorted.effects.BaseEffect; |
| ... | ... | |
| 176 | 177 |
view.getPostRender().restorePreferences(preferences); |
| 177 | 178 |
} |
| 178 | 179 |
|
| 180 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 181 |
|
|
| 182 |
void OpenGLError(String message) |
|
| 183 |
{
|
|
| 184 |
Bundle bundle = new Bundle(); |
|
| 185 |
bundle.putString("error", message );
|
|
| 186 |
|
|
| 187 |
RubikDialogError errDiag = new RubikDialogError(); |
|
| 188 |
errDiag.setArguments(bundle); |
|
| 189 |
errDiag.show(getSupportFragmentManager(), null); |
|
| 190 |
} |
|
| 191 |
|
|
| 179 | 192 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 180 | 193 |
// PUBLIC API |
| 181 | 194 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/main/RubikRenderer.java | ||
|---|---|---|
| 111 | 111 |
crashlytics.setCustomKey("GLSLrenderer" , renderer);
|
| 112 | 112 |
crashlytics.recordException(ex); |
| 113 | 113 |
} |
| 114 |
|
|
| 115 |
RubikActivity act = (RubikActivity)mView.getContext(); |
|
| 116 |
act.OpenGLError(message); |
|
| 114 | 117 |
} |
| 115 | 118 |
} |
| 116 | 119 |
|
| src/main/res/layout/dialog_error.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:gravity="center|fill_horizontal" |
|
| 6 |
android:layout_marginLeft="10dp" |
|
| 7 |
android:layout_marginRight="10dp" |
|
| 8 |
android:layout_marginTop="0dp" |
|
| 9 |
android:background="@color/grey" |
|
| 10 |
android:orientation="vertical"> |
|
| 11 |
|
|
| 12 |
<TextView |
|
| 13 |
android:id="@+id/error_string" |
|
| 14 |
android:layout_width="match_parent" |
|
| 15 |
android:layout_height="match_parent" |
|
| 16 |
android:gravity="center" |
|
| 17 |
android:textSize="24sp" |
|
| 18 |
android:layout_marginTop="10dp" |
|
| 19 |
android:layout_marginLeft="10dp" |
|
| 20 |
android:layout_marginRight="10dp" |
|
| 21 |
android:layout_marginBottom="10dp"/> |
|
| 22 |
</LinearLayout> |
|
| src/main/res/values/strings.xml | ||
|---|---|---|
| 1 | 1 |
<resources> |
| 2 | 2 |
<string name="app_name">Magic Cube</string> |
| 3 | 3 |
<string name="distorted">DISTORTED</string> |
| 4 |
<string name="opengl_error">OpenGL error</string> |
|
| 4 | 5 |
<string name="scramble">Scramble</string> |
| 5 | 6 |
<string name="solve">Solve</string> |
| 6 | 7 |
<string name="exit">Exit</string> |
Also available in: Unified diff
Add OpenGL Error dialog.