From 6fea1b7b8ef1234de2890857ce9423b2a62ce162 Mon Sep 17 00:00:00 2001 From: Boris Timofeev Date: Thu, 31 Aug 2017 11:55:39 +0300 Subject: [PATCH] Globals class was deleted and its contents moved to UniPatcher class --- app/src/main/AndroidManifest.xml | 1 + .../java/org/emunix/unipatcher/Globals.java | 32 ----------------- .../org/emunix/unipatcher/UniPatcher.java | 35 +++++++++++++++++++ .../unipatcher/ui/activity/MainActivity.java | 9 ++--- .../ui/fragment/PatchingFragment.java | 4 +-- 5 files changed, 41 insertions(+), 40 deletions(-) delete mode 100644 app/src/main/java/org/emunix/unipatcher/Globals.java create mode 100644 app/src/main/java/org/emunix/unipatcher/UniPatcher.java diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7643cf8..604fbb8 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -8,6 +8,7 @@ . -*/ - -package org.emunix.unipatcher; - -public class Globals { - private static String cmdArgument = null; - - public static String getCmdArgument() { - return cmdArgument; - } - - public static void setCmdArgument(String cmdArgument) { - Globals.cmdArgument = cmdArgument; - } -} diff --git a/app/src/main/java/org/emunix/unipatcher/UniPatcher.java b/app/src/main/java/org/emunix/unipatcher/UniPatcher.java new file mode 100644 index 0000000..03c5aa5 --- /dev/null +++ b/app/src/main/java/org/emunix/unipatcher/UniPatcher.java @@ -0,0 +1,35 @@ +/* + Copyright (c) 2017 Boris Timofeev + + This file is part of UniPatcher. + + UniPatcher is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + UniPatcher is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with UniPatcher. If not, see . + + */ + +package org.emunix.unipatcher; + +import android.app.Application; + +public class UniPatcher extends Application { + private static String appArgument = null; + + public static String getAppArgument() { + return appArgument; + } + + public static void setAppArgument(String appArgument) { + UniPatcher.appArgument = appArgument; + } +} diff --git a/app/src/main/java/org/emunix/unipatcher/ui/activity/MainActivity.java b/app/src/main/java/org/emunix/unipatcher/ui/activity/MainActivity.java index 925f2ba..780df60 100644 --- a/app/src/main/java/org/emunix/unipatcher/ui/activity/MainActivity.java +++ b/app/src/main/java/org/emunix/unipatcher/ui/activity/MainActivity.java @@ -35,13 +35,12 @@ import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatDelegate; import android.support.v7.preference.PreferenceManager; import android.support.v7.widget.Toolbar; -import android.util.Log; import android.view.MenuItem; import android.view.View; import org.emunix.unipatcher.BuildConfig; -import org.emunix.unipatcher.Globals; import org.emunix.unipatcher.R; +import org.emunix.unipatcher.UniPatcher; import org.emunix.unipatcher.ui.fragment.ActionFragment; import org.emunix.unipatcher.ui.fragment.CreatePatchFragment; import org.emunix.unipatcher.ui.fragment.PatchingFragment; @@ -54,7 +53,6 @@ import static android.support.v7.app.AppCompatDelegate.MODE_NIGHT_YES; public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { - private static final String LOG_TAG = "org.emunix.unipatcher"; @Override protected void onCreate(Bundle savedInstanceState) { @@ -171,10 +169,9 @@ public class MainActivity extends AppCompatActivity private void parseArgument() { try { String arg = getIntent().getData().getPath(); - Globals.setCmdArgument(arg); - Log.d(LOG_TAG, "Cmd argument: " + arg); + UniPatcher.setAppArgument(arg); } catch (NullPointerException e) { - Log.e(LOG_TAG, "NullPointerException in argument fetching"); + // The application is not opened from the file manager } } diff --git a/app/src/main/java/org/emunix/unipatcher/ui/fragment/PatchingFragment.java b/app/src/main/java/org/emunix/unipatcher/ui/fragment/PatchingFragment.java index 4f621d6..57f2da5 100644 --- a/app/src/main/java/org/emunix/unipatcher/ui/fragment/PatchingFragment.java +++ b/app/src/main/java/org/emunix/unipatcher/ui/fragment/PatchingFragment.java @@ -37,9 +37,9 @@ import android.widget.Toast; import org.apache.commons.io.FilenameUtils; import org.emunix.unipatcher.Action; -import org.emunix.unipatcher.Globals; import org.emunix.unipatcher.R; import org.emunix.unipatcher.Settings; +import org.emunix.unipatcher.UniPatcher; import org.emunix.unipatcher.Utils; import org.emunix.unipatcher.WorkerService; import org.emunix.unipatcher.ui.activity.FilePickerActivity; @@ -96,7 +96,7 @@ public class PatchingFragment extends ActionFragment implements View.OnClickList } private void parseArgument() { - patchPath = Globals.getCmdArgument(); + patchPath = UniPatcher.getAppArgument(); if (patchPath != null) { patchNameTextView.setText(new File(patchPath).getName()); }