Revision 1780dcb0
Added by Leszek Koltunski over 5 years ago
| src/main/java/org/distorted/dialogs/RubikDialogAbout.java | ||
|---|---|---|
| 21 | 21 |
|
| 22 | 22 |
import android.app.Dialog; |
| 23 | 23 |
import android.content.DialogInterface; |
| 24 |
import android.content.pm.PackageInfo; |
|
| 25 |
import android.content.pm.PackageManager; |
|
| 24 | 26 |
import android.os.Bundle; |
| 25 | 27 |
import androidx.annotation.NonNull; |
| 26 | 28 |
import androidx.fragment.app.FragmentActivity; |
| ... | ... | |
| 28 | 30 |
import androidx.appcompat.app.AppCompatDialogFragment; |
| 29 | 31 |
|
| 30 | 32 |
import android.text.method.LinkMovementMethod; |
| 33 |
import android.text.method.MovementMethod; |
|
| 31 | 34 |
import android.view.LayoutInflater; |
| 32 | 35 |
import android.view.View; |
| 33 | 36 |
import android.view.Window; |
| ... | ... | |
| 65 | 68 |
final View view = inflater.inflate(R.layout.dialog_about, null); |
| 66 | 69 |
TextView text = view.findViewById(R.id.about_version); |
| 67 | 70 |
String appName = getString(R.string.app_name); |
| 68 |
String appVers = getString(R.string.app_version); |
|
| 71 |
String appVers; |
|
| 72 |
|
|
| 73 |
try |
|
| 74 |
{
|
|
| 75 |
PackageInfo pInfo = act.getPackageManager().getPackageInfo( act.getPackageName(), 0); |
|
| 76 |
appVers = pInfo.versionName; |
|
| 77 |
} |
|
| 78 |
catch (PackageManager.NameNotFoundException e) |
|
| 79 |
{
|
|
| 80 |
appVers = "1.1.1"; |
|
| 81 |
} |
|
| 82 |
|
|
| 69 | 83 |
text.setText(getString(R.string.ap_placeholder,appName, appVers)); |
| 70 | 84 |
|
| 85 |
MovementMethod mm = LinkMovementMethod.getInstance(); |
|
| 71 | 86 |
TextView text1 = view.findViewById(R.id.about_section1); |
| 72 |
text1.setMovementMethod(LinkMovementMethod.getInstance());
|
|
| 87 |
text1.setMovementMethod(mm);
|
|
| 73 | 88 |
TextView text2 = view.findViewById(R.id.about_section2); |
| 74 |
text2.setMovementMethod(LinkMovementMethod.getInstance()); |
|
| 89 |
text2.setMovementMethod(mm); |
|
| 90 |
TextView text3 = view.findViewById(R.id.about_section3); |
|
| 91 |
text3.setMovementMethod(mm); |
|
| 75 | 92 |
|
| 76 | 93 |
builder.setView(view); |
| 77 | 94 |
|
| 78 | 95 |
Dialog dialog = builder.create(); |
| 79 |
|
|
| 80 | 96 |
dialog.setCanceledOnTouchOutside(false); |
| 81 |
|
|
| 82 | 97 |
Window window = dialog.getWindow(); |
| 83 | 98 |
|
| 84 | 99 |
if( window!=null ) |
| src/main/java/org/distorted/scores/RubikScoresDownloader.java | ||
|---|---|---|
| 19 | 19 |
|
| 20 | 20 |
package org.distorted.scores; |
| 21 | 21 |
|
| 22 |
import android.content.pm.PackageInfo; |
|
| 23 |
import android.content.pm.PackageManager; |
|
| 24 |
|
|
| 22 | 25 |
import androidx.fragment.app.FragmentActivity; |
| 23 | 26 |
|
| 24 |
import org.distorted.main.R; |
|
| 25 | 27 |
import org.distorted.objects.RubikObjectList; |
| 26 | 28 |
|
| 27 | 29 |
import java.io.InputStream; |
| ... | ... | |
| 465 | 467 |
|
| 466 | 468 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 467 | 469 |
|
| 468 |
public void download(Receiver receiver, FragmentActivity act)
|
|
| 470 |
private void start(Receiver receiver, FragmentActivity act, int mode)
|
|
| 469 | 471 |
{
|
| 470 | 472 |
mReceiver = receiver; |
| 471 |
mMode = DOWNLOAD; |
|
| 472 |
mVersion = act.getString(R.string.app_version); |
|
| 473 |
mMode = mode; |
|
| 474 |
|
|
| 475 |
try |
|
| 476 |
{
|
|
| 477 |
PackageInfo pInfo = act.getPackageManager().getPackageInfo( act.getPackageName(), 0); |
|
| 478 |
mVersion = pInfo.versionName; |
|
| 479 |
} |
|
| 480 |
catch (PackageManager.NameNotFoundException e) |
|
| 481 |
{
|
|
| 482 |
mVersion = "1.1.1"; |
|
| 483 |
} |
|
| 473 | 484 |
|
| 474 | 485 |
Thread networkThrd = new Thread(this); |
| 475 | 486 |
networkThrd.start(); |
| ... | ... | |
| 477 | 488 |
|
| 478 | 489 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 479 | 490 |
|
| 480 |
public void submit(Receiver receiver, FragmentActivity act)
|
|
| 491 |
public void download(Receiver receiver, FragmentActivity act)
|
|
| 481 | 492 |
{
|
| 482 |
mReceiver = receiver; |
|
| 483 |
mMode = SUBMIT; |
|
| 484 |
mVersion = act.getString(R.string.app_version); |
|
| 493 |
start(receiver, act, DOWNLOAD); |
|
| 494 |
} |
|
| 485 | 495 |
|
| 486 |
Thread networkThrd = new Thread(this); |
|
| 487 |
networkThrd.start(); |
|
| 496 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 497 |
|
|
| 498 |
public void submit(Receiver receiver, FragmentActivity act) |
|
| 499 |
{
|
|
| 500 |
start(receiver, act, SUBMIT); |
|
| 488 | 501 |
} |
| 489 | 502 |
} |
| src/main/res/values/strings.xml | ||
|---|---|---|
| 1 | 1 |
<resources> |
| 2 | 2 |
<string name="app_name">Magic Cube</string> |
| 3 |
<string name="app_version">1.1.1</string> |
|
| 4 | 3 |
<string name="distorted">DISTORTED</string> |
| 5 | 4 |
<string name="scramble">Scramble</string> |
| 6 | 5 |
<string name="solve">Solve</string> |
Also available in: Unified diff
Fix clicking on the 'Distorted.org' link; get app version from build.gradle (and not from strings.xml)