Skip to content

Commit

Permalink
v1.1.0: Ability to disable operators, support me\! buttons in about p…
Browse files Browse the repository at this point in the history
…ane.
  • Loading branch information
Emzi0767 committed Jul 12, 2018
1 parent 4a20329 commit dd65432
Show file tree
Hide file tree
Showing 27 changed files with 974 additions and 119 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
# Changelog for R6: Strat Roulette

### v1.1.0 (released: 2018-07-12 01:21 +02:00)
- FIX: Bumped minimum required Android version to 5.0, as 4.4 does not support modern TLS versions
required to download assets.
- NEW: Settings menu
- Settings allow you to control which operators are available to you
- Operator randomization will not randomize from disabled operator pool
- In the future, more options may be made available in here
- NEW: Support via PayPal and Patreon buttons in about pane

### v1.0.2 (released: 2018-06-30 19:31 +02:00)
- FIX: No internet connection or unreachable asset server no longer prevents aplication from being
- FIX: No internet connection or unreachable asset server no longer prevent aplication from being
used
- FIX: Windows are now longer leaked
- NEW: Application no longer requires external storage access
Expand Down
9 changes: 5 additions & 4 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ The application requires 4 permissions to run:
* **Access network state** to check whether internet connection is available

## Installation
As the application is not (yet) available in Play Store, you will need to sideload it. First, you
need to ensure that your device allows installing applications from outside of Play Store. To do
that, you need to go to **Settings > Security & privacy > Additional settings** and make
sure that **Unknown sources** is checked.
The application [is available in Play Store](https://play.google.com/store/apps/details?id=com.emzi0767.r6stratroulette).
However, if you insist on sideloading, you can still do that. First, you need to ensure that your
device allows installing applications from outside of Play Store. To do that, you need to go to
**Settings > Security & privacy > Additional settings** and make sure that **Unknown
sources** is checked.

### Installing using just the device
Open your browser and navigate to [the download page](https://github.com/Emzi0767/R6-Strat-Roulette/releases/latest).
Expand Down
10 changes: 5 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@ android {
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.emzi0767.r6stratroulette"
minSdkVersion 19
minSdkVersion 20
targetSdkVersion 27
versionCode 3
versionName "1.0.2"
versionCode 4
versionName "1.1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
applicationIdSuffix ".debug"
versionNameSuffix "-DEBUG"
applicationIdSuffix '.debug'
versionNameSuffix '-DEBUG'
}
}
compileOptions {
Expand Down
15 changes: 9 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
This file is a part of R6: Strat Roulette project.
Copyright 2018 Emzi0767
Expand All @@ -16,10 +15,12 @@
See the License for the specific language governing permissions and
limitations under the License.
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.emzi0767.r6stratroulette">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
Expand All @@ -33,9 +34,11 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".SettingsActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.emzi0767.r6stratroulette.MainActivity" />
</activity>
</application>

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@

package com.emzi0767.r6stratroulette;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

/**
Expand All @@ -48,7 +51,21 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_about, container, false);
View v = inflater.inflate(R.layout.fragment_about, container, false);

Button supportPP = v.findViewById(R.id.btn_about_support_paypal);
supportPP.setOnClickListener(x -> {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(this.getString(R.string.about_paypal_url)));
this.startActivity(browserIntent);
});

Button supportPT = v.findViewById(R.id.btn_about_support_patreon);
supportPT.setOnClickListener(x -> {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(this.getString(R.string.about_patreon_url)));
this.startActivity(browserIntent);
});

return v;
}

}
25 changes: 25 additions & 0 deletions app/src/main/java/com/emzi0767/r6stratroulette/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import android.annotation.TargetApi;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
Expand All @@ -30,6 +31,7 @@
import android.support.design.widget.NavigationView;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.GravityCompat;
Expand Down Expand Up @@ -253,6 +255,14 @@ private void setView(int id, ActionBar actionBar) {
t.replace(R.id.content_frame, this.strategyRoulette);
break;

case R.id.nav_drawer_settings:
t.commit();
Intent intent = new Intent(this, SettingsActivity.class);
intent.putExtra("rouletteData", this.rouletteData)
.putExtra("assetLocation", this.assetLocation.getAbsolutePath());
ActivityCompat.startActivityForResult(this, intent, 1, null);
return;

case R.id.nav_drawer_about:
if (this.about.isDetached())
t.attach(this.about);
Expand Down Expand Up @@ -504,11 +514,26 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
this.releaseSemaphoreIfPermissionsGranted();
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);

if (requestCode == 1 && resultCode == 1) {
FragmentManager fm = this.getSupportFragmentManager();
Fragment f = fm.findFragmentById(R.id.content_frame);
fm.beginTransaction().detach(f).attach(f).commit();
}
}

public RouletteData getRouletteData() {
return this.rouletteData;
}

public File getAssetLocation() {
return this.assetLocation;
}

public ThreadPoolExecutor getThreadPool() {
return this.threadPool;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package com.emzi0767.r6stratroulette;

import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
Expand All @@ -34,67 +36,44 @@
import com.emzi0767.r6stratroulette.models.RouletteData;

import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.*;

/**
* A simple {@link Fragment} subclass.
*/
public class OperatorRandomizerFragment extends Fragment {
private RouletteData rouletteData = null;
private File assetLocation = null;
private ArrayList<OperatorData> atks = null, defs = null;

private Bitmap bmpA = null, bmpD = null;
private OperatorData opA = null, opD = null;

private ImageView imgAttacker = null, imgDefender = null;
private TextView nameAttacker = null, nameDefender = null, ctuAttacker = null, ctuDefender = null;

private MainActivity mainActivity = null;

private final Random rng = new Random();

public OperatorRandomizerFragment() {
}

@Override
public void onAttach(Context context) {
super.onAttach(context);
this.initOperators(null);
}

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);

MainActivity ac = (MainActivity)this.getActivity();
this.rouletteData = ac.getRouletteData();
this.assetLocation = ac.getAssetLocation();

OperatorsData ops = this.rouletteData.getOperators();
List<OperatorData> atks = ops.getAttackers();
List<OperatorData> defs = ops.getDefenders();

OperatorData atk = null;
OperatorData def = null;

if (savedInstanceState != null && savedInstanceState.containsKey("ATTACKER") && savedInstanceState.containsKey("DEFENDER")) {
String atkN = savedInstanceState.getString("ATTACKER");
String defN = savedInstanceState.getString("DEFENDER");

for (OperatorData op : atks)
if (op.getName().equals(atkN)) {
atk = op;
break;
}
for (OperatorData op : defs)
if (op.getName().equals(defN)) {
def = op;
break;
}
} else {
int ra = this.rng.nextInt(atks.size());
int rd = this.rng.nextInt(defs.size());

atk = atks.get(ra);
def = defs.get(rd);
}
this.mainActivity = (MainActivity)this.getActivity();
this.rouletteData = this.mainActivity.getRouletteData();
this.assetLocation = this.mainActivity.getAssetLocation();

if (atk != null && def != null)
this.setOperators(atk, def);
this.initOperators(savedInstanceState);
}

@Override
Expand All @@ -112,15 +91,11 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,

Button btn = v.findViewById(R.id.randomop_randomize);
btn.setOnClickListener(b -> {
OperatorsData ops = this.rouletteData.getOperators();
List<OperatorData> atks = ops.getAttackers();
List<OperatorData> defs = ops.getDefenders();

int ra = this.rng.nextInt(atks.size());
int rd = this.rng.nextInt(defs.size());
int ra = this.rng.nextInt(this.atks.size());
int rd = this.rng.nextInt(this.defs.size());

OperatorData atk = atks.get(ra);
OperatorData def = defs.get(rd);
OperatorData atk = this.atks.get(ra);
OperatorData def = this.defs.get(rd);

this.setOperators(atk, def);
});
Expand Down Expand Up @@ -162,4 +137,54 @@ private void setOperators(OperatorData atk, OperatorData def) {
imgAttacker.setImageBitmap(bmpA);
imgDefender.setImageBitmap(bmpD);
}

private void initOperators(Bundle savedInstanceState) {
if (this.mainActivity == null)
return;

SharedPreferences prefs = this.mainActivity.getSharedPreferences(this.getString(R.string.settings_filename), Context.MODE_PRIVATE);
Set<String> disabledOps = prefs.getStringSet(SettingsActivity.DISABLED_OPS_KEY, new HashSet<>());

OperatorsData ops = this.rouletteData.getOperators();
List<OperatorData> xatks = ops.getAttackers();
List<OperatorData> xdefs = ops.getDefenders();
this.atks = new ArrayList<>();
this.defs = new ArrayList<>();

for (OperatorData op : xatks)
if (!disabledOps.contains(op.getName()))
this.atks.add(op);
for (OperatorData op : xdefs)
if (!disabledOps.contains(op.getName()))
this.defs.add(op);

OperatorData atk = null;
OperatorData def = null;

if (savedInstanceState != null && savedInstanceState.containsKey("ATTACKER") && savedInstanceState.containsKey("DEFENDER")) {
String atkN = savedInstanceState.getString("ATTACKER");
String defN = savedInstanceState.getString("DEFENDER");

for (OperatorData op : this.atks)
if (op.getName().equals(atkN)) {
atk = op;
break;
}
for (OperatorData op : this.defs)
if (op.getName().equals(defN)) {
def = op;
break;
}
}

if (atk == null || def == null) {
int ra = this.rng.nextInt(this.atks.size());
int rd = this.rng.nextInt(this.defs.size());

atk = this.atks.get(ra);
def = this.defs.get(rd);
}

this.setOperators(atk, def);
}
}
Loading

0 comments on commit dd65432

Please sign in to comment.