From f5e53cd60f9c9b626022bc1980510937a066565e Mon Sep 17 00:00:00 2001 From: dvdandroid Date: Sun, 21 Aug 2016 15:29:42 +0200 Subject: [PATCH] Start materializing module fragment --- .gitignore | 4 +- .idea/misc.xml | 2 +- app/build.gradle | 12 +- app/src/main/AndroidManifest.xml | 7 +- .../com/topjohnwu/magisk/WelcomeActivity.java | 121 ++++++++++++++++++ .../com/topjohnwu/magisk/model/Module.java | 8 -- .../topjohnwu/magisk/rv/ModulesAdapter.java | 88 +++++++------ .../com/topjohnwu/magisk/ui/LogFragment.java | 5 + .../com/topjohnwu/magisk/ui/MainActivity.java | 22 ++-- ...ulesActivity.java => ModulesFragment.java} | 49 +++++-- .../com/topjohnwu/magisk/ui/RootFragment.java | 4 + app/src/main/res/anim/fade_in.xml | 8 ++ app/src/main/res/anim/fade_out.xml | 8 ++ .../res/drawable-anydpi/ic_bug_report.xml | 9 ++ .../main/res/drawable-anydpi/ic_extension.xml | 9 ++ app/src/main/res/drawable/root.xml | 9 ++ app/src/main/res/layout/activity_welcome.xml | 41 ++++++ app/src/main/res/layout/modules_fragment.xml | 15 +++ app/src/main/res/layout/row.xml | 98 ++++++++++---- app/src/main/res/menu/drawer.xml | 28 ++++ app/src/main/res/values/colors.xml | 13 +- app/src/main/res/values/strings.xml | 9 ++ app/src/main/res/values/styles.xml | 20 ++- build.gradle | 2 + .../rootcommands/Remounter.java | 3 +- .../rootcommands/RootCommands.java | 2 +- .../rootcommands/Shell.java | 3 +- .../rootcommands/Toolbox.java | 2 +- .../rootcommands/command/Command.java | 3 +- .../rootcommands/util/Log.java | 82 ------------ .../rootcommands/util/Utils.java | 2 + 31 files changed, 495 insertions(+), 193 deletions(-) create mode 100644 app/src/main/java/com/topjohnwu/magisk/WelcomeActivity.java create mode 100644 app/src/main/java/com/topjohnwu/magisk/ui/LogFragment.java rename app/src/main/java/com/topjohnwu/magisk/ui/{ModulesActivity.java => ModulesFragment.java} (58%) create mode 100644 app/src/main/java/com/topjohnwu/magisk/ui/RootFragment.java create mode 100644 app/src/main/res/anim/fade_in.xml create mode 100644 app/src/main/res/anim/fade_out.xml create mode 100644 app/src/main/res/drawable-anydpi/ic_bug_report.xml create mode 100644 app/src/main/res/drawable-anydpi/ic_extension.xml create mode 100644 app/src/main/res/drawable/root.xml create mode 100644 app/src/main/res/layout/activity_welcome.xml create mode 100644 app/src/main/res/layout/modules_fragment.xml create mode 100644 app/src/main/res/menu/drawer.xml delete mode 100644 lib/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/util/Log.java diff --git a/.gitignore b/.gitignore index 1fe4b4f12..fda3654d5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ *.iml .gradle /local.properties -/.idea/ -/build +.idea/ +/build \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 0fa1f5670..471660067 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -37,7 +37,7 @@ - + diff --git a/app/build.gradle b/app/build.gradle index 1682655a2..ccbc5c99a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,4 +1,5 @@ apply plugin: 'com.android.application' +apply plugin: 'android-apt' android { compileSdkVersion 24 @@ -10,10 +11,6 @@ android { targetSdkVersion 24 versionCode 3 versionName "v4" - - jackOptions { - enabled true - } } buildTypes { release { @@ -24,6 +21,11 @@ android { } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) + compile fileTree(include: ['*.jar'], dir: 'libs') compile project(':lib:RootCommands') + compile 'com.android.support:recyclerview-v7:24.2.0' + compile 'com.android.support:cardview-v7:24.2.0' + compile 'com.android.support:design:24.2.0' + compile 'com.jakewharton:butterknife:8.2.1' + apt 'com.jakewharton:butterknife-compiler:8.2.1' } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index f3c51b779..c5d0b66b3 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -15,7 +15,12 @@ - + + + + + + diff --git a/app/src/main/java/com/topjohnwu/magisk/WelcomeActivity.java b/app/src/main/java/com/topjohnwu/magisk/WelcomeActivity.java new file mode 100644 index 000000000..3532d1505 --- /dev/null +++ b/app/src/main/java/com/topjohnwu/magisk/WelcomeActivity.java @@ -0,0 +1,121 @@ +package com.topjohnwu.magisk; + +import android.os.Bundle; +import android.os.Handler; +import android.support.annotation.NonNull; +import android.support.design.widget.NavigationView; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentTransaction; +import android.support.v4.view.GravityCompat; +import android.support.v4.widget.DrawerLayout; +import android.support.v7.app.ActionBarDrawerToggle; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; +import android.view.MenuItem; +import android.view.View; + +import com.topjohnwu.magisk.ui.LogFragment; +import com.topjohnwu.magisk.ui.ModulesFragment; +import com.topjohnwu.magisk.ui.RootFragment; + +import butterknife.BindView; +import butterknife.ButterKnife; + +public class WelcomeActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { + + private static final String SELECTED_ITEM_ID = "SELECTED_ITEM_ID"; + private final Handler mDrawerHandler = new Handler(); + + @BindView(R.id.toolbar) Toolbar toolbar; + @BindView(R.id.drawer_layout) DrawerLayout drawer; + @BindView(R.id.nav_view) NavigationView navigationView; + + @Override + protected void onCreate(final Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_welcome); + ButterKnife.bind(this); + + setSupportActionBar(toolbar); + + ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close) { + @Override + public void onDrawerOpened(View drawerView) { + super.onDrawerOpened(drawerView); + super.onDrawerSlide(drawerView, 0); // this disables the arrow @ completed state + } + + @Override + public void onDrawerSlide(View drawerView, float slideOffset) { + super.onDrawerSlide(drawerView, 0); // this disables the animation + } + }; + + drawer.setDrawerListener(toggle); + toggle.syncState(); + + navigationView.setNavigationItemSelectedListener(this); + + if (savedInstanceState != null) { + mDrawerHandler.removeCallbacksAndMessages(null); + mDrawerHandler.postDelayed(new Runnable() { + @Override + public void run() { + navigate(savedInstanceState.getInt(SELECTED_ITEM_ID)); + } + }, 250); + } + + } + + @Override + public void onBackPressed() { + if (drawer.isDrawerOpen(GravityCompat.START)) { + drawer.closeDrawer(GravityCompat.START); + } else { + super.onBackPressed(); + } + } + + @Override + public boolean onNavigationItemSelected(@NonNull final MenuItem menuItem) { + menuItem.setChecked(true); + mDrawerHandler.removeCallbacksAndMessages(null); + mDrawerHandler.postDelayed(new Runnable() { + @Override + public void run() { + navigate(menuItem.getItemId()); + } + }, 250); + + drawer.closeDrawer(GravityCompat.START); + return true; + } + + private void navigate(final int itemId) { + Fragment navFragment = null; + switch (itemId) { + case R.id.root: + setTitle(R.string.root); + navFragment = new RootFragment(); + break; + case R.id.modules: + setTitle(R.string.modules); + navFragment = new ModulesFragment(); + break; + case R.id.log: + setTitle(R.string.log); + navFragment = new LogFragment(); + break; + } + + if (navFragment != null) { + FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); + transaction.setCustomAnimations(R.anim.fade_in, R.anim.fade_out); + try { + transaction.replace(R.id.content_frame, navFragment).commit(); + } catch (IllegalStateException ignored) { + } + } + } +} diff --git a/app/src/main/java/com/topjohnwu/magisk/model/Module.java b/app/src/main/java/com/topjohnwu/magisk/model/Module.java index 657354e8a..3958c79ca 100644 --- a/app/src/main/java/com/topjohnwu/magisk/model/Module.java +++ b/app/src/main/java/com/topjohnwu/magisk/model/Module.java @@ -12,7 +12,6 @@ public class Module { private String mName; private String mVersion; - private int mVersionCode; private String mDescription; public Module(File file) { @@ -36,10 +35,6 @@ public class Module { return mName; } - public int getVersionCode() { - return mVersionCode; - } - public String getVersion() { return mVersion; } @@ -70,9 +65,6 @@ public class Module { case "version": mVersion = value; break; - case "versionCode": - mVersionCode = Integer.parseInt(value); - break; case "description": mDescription = value; break; diff --git a/app/src/main/java/com/topjohnwu/magisk/rv/ModulesAdapter.java b/app/src/main/java/com/topjohnwu/magisk/rv/ModulesAdapter.java index 1afd95794..1ad675623 100644 --- a/app/src/main/java/com/topjohnwu/magisk/rv/ModulesAdapter.java +++ b/app/src/main/java/com/topjohnwu/magisk/rv/ModulesAdapter.java @@ -1,11 +1,9 @@ package com.topjohnwu.magisk.rv; -import android.annotation.SuppressLint; -import android.content.Context; +import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.ArrayAdapter; import android.widget.TextView; import com.topjohnwu.magisk.R; @@ -13,48 +11,60 @@ import com.topjohnwu.magisk.model.Module; import java.util.List; -public class ModulesAdapter extends ArrayAdapter { +import butterknife.BindView; +import butterknife.ButterKnife; - public ModulesAdapter(Context context, int resource, List modules) { - super(context, resource, modules); +public class ModulesAdapter extends RecyclerView.Adapter { + + private final List mList; + + public ModulesAdapter(List mList) { + this.mList = mList; } - @SuppressLint("SetTextI18n") @Override - public View getView(int position, View convertView, ViewGroup parent) { - ViewHolder vh; + public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.row, parent, false); +/*FIXME + final ViewHolder viewHolder = new ViewHolder(view); + view.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + listener.onItemClick(viewHolder.getAdapterPosition()); + } + });*/ - if (convertView == null) { - LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); - convertView = inflater.inflate(R.layout.row, null); - - vh = new ViewHolder(); - vh.name = (TextView) convertView.findViewById(R.id.name); - vh.version = (TextView) convertView.findViewById(R.id.version); - vh.versionCode = (TextView) convertView.findViewById(R.id.versionCode); - vh.description = (TextView) convertView.findViewById(R.id.description); - vh.cache = (TextView) convertView.findViewById(R.id.cache); - - convertView.setTag(vh); - } else { - vh = (ViewHolder) convertView.getTag(); - } - - Module module = getItem(position); - vh.name.setText("name= " + module.getName()); - vh.version.setText("version= " + module.getVersion()); - vh.versionCode.setText("versioncode= " + module.getVersionCode()); - vh.description.setText("description= " + module.getDescription()); - vh.cache.setText("is from cache= " + module.isCache()); - - return convertView; + return new ViewHolder(view); } - static class ViewHolder { - public TextView name; - public TextView version; - public TextView versionCode; - public TextView description; - public TextView cache; + @Override + public void onBindViewHolder(ViewHolder holder, int position) { + Module module = mList.get(position); + + holder.title.setText(module.getName()); + holder.versionName.setText(module.getVersion()); + holder.description.setText(module.getDescription()); + + //FIXME + + //holder.cache.setText("" + module.isCache()); + } + + @Override + public int getItemCount() { + return mList.size(); + } + + static class ViewHolder extends RecyclerView.ViewHolder { + + @BindView(R.id.title) TextView title; + @BindView(R.id.version_name) TextView versionName; + @BindView(R.id.description) TextView description; + //@BindView(R.id.cache) TextView cache; + + public ViewHolder(View itemView) { + super(itemView); + ButterKnife.bind(this, itemView); + } } } \ No newline at end of file diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/LogFragment.java b/app/src/main/java/com/topjohnwu/magisk/ui/LogFragment.java new file mode 100644 index 000000000..d1b9fa221 --- /dev/null +++ b/app/src/main/java/com/topjohnwu/magisk/ui/LogFragment.java @@ -0,0 +1,5 @@ +package com.topjohnwu.magisk.ui; + +public class LogFragment extends android.support.v4.app.Fragment { +// private static final String MAGISK_LOG = "/cache/magisk.log"; +} diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.java b/app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.java index 0a6b834a9..78e415df9 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.java +++ b/app/src/main/java/com/topjohnwu/magisk/ui/MainActivity.java @@ -1,9 +1,9 @@ package com.topjohnwu.magisk.ui; import android.app.Activity; -import android.content.Intent; import android.graphics.Color; import android.os.Bundle; +import android.widget.CompoundButton; import android.widget.Switch; import android.widget.TextView; @@ -35,17 +35,23 @@ public class MainActivity extends Activity { suPath = executeCommand("getprop magisk.supath"); updateStatus(); - rootToggle.setOnCheckedChangeListener((view, checked) -> { - executeCommand(checked ? "setprop magisk.root 1" : "setprop magisk.root 0"); - updateStatus(); + rootToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean b) { + executeCommand(b ? "setprop magisk.root 1" : "setprop magisk.root 0"); + updateStatus(); + } }); - selinuxToggle.setOnCheckedChangeListener((view, checked) -> { - executeCommand(checked ? "setenforce 1" : "setenforce 0"); - updateStatus(); + selinuxToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean b) { + executeCommand(b ? "setenforce 1" : "setenforce 0"); + updateStatus(); + } }); - findViewById(R.id.modules).setOnClickListener(view -> startActivity(new Intent(this, ModulesActivity.class))); + //findViewById(R.id.modules).setOnClickListener(view -> startActivity(new Intent(this, ModulesActivity.class))); } private void updateStatus() { diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/ModulesActivity.java b/app/src/main/java/com/topjohnwu/magisk/ui/ModulesFragment.java similarity index 58% rename from app/src/main/java/com/topjohnwu/magisk/ui/ModulesActivity.java rename to app/src/main/java/com/topjohnwu/magisk/ui/ModulesFragment.java index b6dca6580..2ec235119 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/ModulesActivity.java +++ b/app/src/main/java/com/topjohnwu/magisk/ui/ModulesFragment.java @@ -1,35 +1,45 @@ package com.topjohnwu.magisk.ui; -import android.app.Activity; import android.app.ProgressDialog; import android.os.AsyncTask; import android.os.Bundle; -import android.widget.ListView; +import android.support.annotation.Nullable; +import android.support.v7.widget.RecyclerView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; import com.topjohnwu.magisk.R; import com.topjohnwu.magisk.model.Module; import com.topjohnwu.magisk.rv.ModulesAdapter; +import com.topjohnwu.magisk.ui.utils.Utils; import java.io.File; +import java.io.FileFilter; import java.util.ArrayList; import java.util.List; -public class ModulesActivity extends Activity { +import butterknife.BindView; +import butterknife.ButterKnife; + +public class ModulesFragment extends android.support.v4.app.Fragment { private static final String MAGISK_PATH = "/magisk"; private static final String MAGISK_CACHE_PATH = "/cache/magisk"; + @BindView(R.id.recyclerView) RecyclerView recyclerView; + private List listModules = new ArrayList<>(); - private ListView mListView; + @Nullable @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_modules); - - mListView = (ListView) findViewById(android.R.id.list); + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { + View v = inflater.inflate(R.layout.modules_fragment, container, false); + ButterKnife.bind(this, v); new CheckFolders().execute(); + + return v; } private class CheckFolders extends AsyncTask { @@ -40,13 +50,26 @@ public class ModulesActivity extends Activity { protected void onPreExecute() { super.onPreExecute(); - progress = ProgressDialog.show(ModulesActivity.this, null, getString(R.string.loading), true, false); + progress = ProgressDialog.show(getContext(), null, getString(R.string.loading), true, false); } @Override protected Boolean doInBackground(Void... voids) { - File[] magisk = new File(MAGISK_PATH).listFiles(File::isDirectory); - File[] magiskCache = new File(MAGISK_CACHE_PATH).listFiles(File::isDirectory); + File[] magisk = new File(MAGISK_PATH).listFiles(new FileFilter() { + @Override + public boolean accept(File file) { + return file.isDirectory(); + } + }); + + Utils.executeCommand("chmod 777 /cache"); + + File[] magiskCache = new File(MAGISK_CACHE_PATH).listFiles(new FileFilter() { + @Override + public boolean accept(File file) { + return file.isDirectory(); + } + }); if (magisk != null) { for (File mod : magisk) { @@ -83,7 +106,7 @@ public class ModulesActivity extends Activity { progress.dismiss(); - mListView.setAdapter(new ModulesAdapter(ModulesActivity.this, R.layout.row, listModules)); + recyclerView.setAdapter(new ModulesAdapter(listModules)); } } diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/RootFragment.java b/app/src/main/java/com/topjohnwu/magisk/ui/RootFragment.java new file mode 100644 index 000000000..14608b94a --- /dev/null +++ b/app/src/main/java/com/topjohnwu/magisk/ui/RootFragment.java @@ -0,0 +1,4 @@ +package com.topjohnwu.magisk.ui; + +public class RootFragment extends android.support.v4.app.Fragment { +} diff --git a/app/src/main/res/anim/fade_in.xml b/app/src/main/res/anim/fade_in.xml new file mode 100644 index 000000000..f1d8eed54 --- /dev/null +++ b/app/src/main/res/anim/fade_in.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/anim/fade_out.xml b/app/src/main/res/anim/fade_out.xml new file mode 100644 index 000000000..a5f9254e1 --- /dev/null +++ b/app/src/main/res/anim/fade_out.xml @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable-anydpi/ic_bug_report.xml b/app/src/main/res/drawable-anydpi/ic_bug_report.xml new file mode 100644 index 000000000..0ac39ddc1 --- /dev/null +++ b/app/src/main/res/drawable-anydpi/ic_bug_report.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable-anydpi/ic_extension.xml b/app/src/main/res/drawable-anydpi/ic_extension.xml new file mode 100644 index 000000000..80d25de23 --- /dev/null +++ b/app/src/main/res/drawable-anydpi/ic_extension.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/root.xml b/app/src/main/res/drawable/root.xml new file mode 100644 index 000000000..bca20e4d8 --- /dev/null +++ b/app/src/main/res/drawable/root.xml @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_welcome.xml b/app/src/main/res/layout/activity_welcome.xml new file mode 100644 index 000000000..b4f712cbc --- /dev/null +++ b/app/src/main/res/layout/activity_welcome.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/modules_fragment.xml b/app/src/main/res/layout/modules_fragment.xml new file mode 100644 index 000000000..1495adf5c --- /dev/null +++ b/app/src/main/res/layout/modules_fragment.xml @@ -0,0 +1,15 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/row.xml b/app/src/main/res/layout/row.xml index f4f85bda6..bb11a9346 100644 --- a/app/src/main/res/layout/row.xml +++ b/app/src/main/res/layout/row.xml @@ -1,32 +1,80 @@ - + - + - + - + - + - + - \ No newline at end of file + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/drawer.xml b/app/src/main/res/menu/drawer.xml new file mode 100644 index 000000000..dd1f2bf55 --- /dev/null +++ b/app/src/main/res/menu/drawer.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 9ad7e369a..63eda8419 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -1,6 +1,13 @@ - #3f51b5 - #303F9F - #FF4081 + + #009688 + #00796B + #B2DFDB + #FFC107 + #212121 + #757575 + #FFFFFF + #BDBDBD + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 26c92bc60..969b5bd76 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -19,4 +19,13 @@ Magisk v%1$s Samsung do not support switching SELinux status! Loading... + WelcomeActivity + + Open navigation drawer + Close navigation drawer + + Settings + Root + Modules + Log diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 1e7a95eb8..a639011f3 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -1,6 +1,24 @@ - + + diff --git a/build.gradle b/build.gradle index 77ce66ea3..4ec4cf5f1 100644 --- a/build.gradle +++ b/build.gradle @@ -3,9 +3,11 @@ buildscript { repositories { jcenter() + mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:2.1.3' + classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/lib/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/Remounter.java b/lib/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/Remounter.java index f575e0dd1..8f20a5608 100644 --- a/lib/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/Remounter.java +++ b/lib/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/Remounter.java @@ -17,8 +17,9 @@ package org.sufficientlysecure.rootcommands; +import android.util.Log; + import org.sufficientlysecure.rootcommands.command.SimpleCommand; -import org.sufficientlysecure.rootcommands.util.Log; import java.io.File; import java.io.FileReader; diff --git a/lib/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/RootCommands.java b/lib/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/RootCommands.java index 67e583757..a4036e20a 100644 --- a/lib/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/RootCommands.java +++ b/lib/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/RootCommands.java @@ -16,7 +16,7 @@ package org.sufficientlysecure.rootcommands; -import org.sufficientlysecure.rootcommands.util.Log; +import android.util.Log; public class RootCommands { public static final String TAG = "RootCommands"; diff --git a/lib/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/Shell.java b/lib/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/Shell.java index 74aa0bfe3..88a65537c 100644 --- a/lib/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/Shell.java +++ b/lib/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/Shell.java @@ -17,8 +17,9 @@ package org.sufficientlysecure.rootcommands; +import android.util.Log; + import org.sufficientlysecure.rootcommands.command.Command; -import org.sufficientlysecure.rootcommands.util.Log; import org.sufficientlysecure.rootcommands.util.RootAccessDeniedException; import org.sufficientlysecure.rootcommands.util.Utils; diff --git a/lib/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/Toolbox.java b/lib/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/Toolbox.java index 9f2a7fbd0..b36546fbb 100644 --- a/lib/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/Toolbox.java +++ b/lib/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/Toolbox.java @@ -19,12 +19,12 @@ package org.sufficientlysecure.rootcommands; import android.os.StatFs; import android.os.SystemClock; +import android.util.Log; import org.sufficientlysecure.rootcommands.command.Command; import org.sufficientlysecure.rootcommands.command.ExecutableCommand; import org.sufficientlysecure.rootcommands.command.SimpleCommand; import org.sufficientlysecure.rootcommands.util.BrokenBusyboxException; -import org.sufficientlysecure.rootcommands.util.Log; import java.io.File; import java.io.FileNotFoundException; diff --git a/lib/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/command/Command.java b/lib/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/command/Command.java index e7e54781c..ce02f9ea2 100644 --- a/lib/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/command/Command.java +++ b/lib/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/command/Command.java @@ -17,10 +17,11 @@ package org.sufficientlysecure.rootcommands.command; +import android.util.Log; + import org.sufficientlysecure.rootcommands.RootCommands; import org.sufficientlysecure.rootcommands.Shell; import org.sufficientlysecure.rootcommands.util.BrokenBusyboxException; -import org.sufficientlysecure.rootcommands.util.Log; import java.io.IOException; import java.io.OutputStream; diff --git a/lib/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/util/Log.java b/lib/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/util/Log.java deleted file mode 100644 index 337c49d41..000000000 --- a/lib/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/util/Log.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2012 Dominik Schürmann - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.sufficientlysecure.rootcommands.util; - -import org.sufficientlysecure.rootcommands.RootCommands; - -/** - * Wraps Android Logging to enable or disable debug output using Constants - */ -public final class Log { - - public static void v(String tag, String msg) { - if (RootCommands.DEBUG) { - android.util.Log.v(tag, msg); - } - } - - public static void v(String tag, String msg, Throwable tr) { - if (RootCommands.DEBUG) { - android.util.Log.v(tag, msg, tr); - } - } - - public static void d(String tag, String msg) { - if (RootCommands.DEBUG) { - android.util.Log.d(tag, msg); - } - } - - public static void d(String tag, String msg, Throwable tr) { - if (RootCommands.DEBUG) { - android.util.Log.d(tag, msg, tr); - } - } - - public static void i(String tag, String msg) { - if (RootCommands.DEBUG) { - android.util.Log.i(tag, msg); - } - } - - public static void i(String tag, String msg, Throwable tr) { - if (RootCommands.DEBUG) { - android.util.Log.i(tag, msg, tr); - } - } - - public static void w(String tag, String msg) { - android.util.Log.w(tag, msg); - } - - public static void w(String tag, String msg, Throwable tr) { - android.util.Log.w(tag, msg, tr); - } - - public static void w(String tag, Throwable tr) { - android.util.Log.w(tag, tr); - } - - public static void e(String tag, String msg) { - android.util.Log.e(tag, msg); - } - - public static void e(String tag, String msg, Throwable tr) { - android.util.Log.e(tag, msg, tr); - } - -} diff --git a/lib/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/util/Utils.java b/lib/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/util/Utils.java index e04d4dbd0..1aab0a0a1 100644 --- a/lib/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/util/Utils.java +++ b/lib/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/util/Utils.java @@ -18,6 +18,8 @@ package org.sufficientlysecure.rootcommands.util; +import android.util.Log; + import org.sufficientlysecure.rootcommands.RootCommands; import java.io.File;