]> git.ktnx.net Git - mobile-ledger.git/commitdiff
Move ProfileDetailActivity under activity/
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 17 Feb 2019 19:56:43 +0000 (21:56 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 17 Feb 2019 20:02:59 +0000 (22:02 +0200)
app/src/main/AndroidManifest.xml
app/src/main/java/net/ktnx/mobileledger/ui/activity/ProfileDetailActivity.java [new file with mode: 0644]
app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailActivity.java [deleted file]
app/src/main/res/layout/activity_profile_detail.xml

index 83953a0ca3052d74940f8c4e430791d541421ff9..eec9d79baaa339234a67d0d04b597eaa112836ce 100644 (file)
@@ -60,7 +60,7 @@
             android:label="@string/title_profile_list"
             android:theme="@style/AppTheme.NoActionBar"></activity>
         <activity
-            android:name=".ui.profiles.ProfileDetailActivity"
+            android:name=".ui.activity.ProfileDetailActivity"
             android:label="@string/title_profile_details"
             android:parentActivityName=".ui.activity.ProfileListActivity"
             android:theme="@style/AppTheme.NoActionBar">
diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/ProfileDetailActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/ProfileDetailActivity.java
new file mode 100644 (file)
index 0000000..ccdad2c
--- /dev/null
@@ -0,0 +1,135 @@
+/*
+ * Copyright © 2019 Damyan Ivanov.
+ * This file is part of MoLe.
+ * MoLe is free software: you can distribute it and/or modify it
+ * under the term of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your opinion), any later version.
+ *
+ * MoLe 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 terms for details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MoLe. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package net.ktnx.mobileledger.ui.activity;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.design.widget.FloatingActionButton;
+import android.support.design.widget.Snackbar;
+import android.support.v7.app.ActionBar;
+import android.support.v7.widget.Toolbar;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+
+import net.ktnx.mobileledger.R;
+import net.ktnx.mobileledger.model.Data;
+import net.ktnx.mobileledger.model.MobileLedgerProfile;
+import net.ktnx.mobileledger.ui.activity.CrashReportingActivity;
+import net.ktnx.mobileledger.ui.activity.ProfileListActivity;
+import net.ktnx.mobileledger.ui.profiles.ProfileDetailFragment;
+
+/**
+ * An activity representing a single Profile detail screen. This
+ * activity is only used on narrow width devices. On tablet-size devices,
+ * item details are presented side-by-side with a list of items
+ * in a {@link ProfileListActivity}.
+ */
+public class ProfileDetailActivity extends CrashReportingActivity {
+    private MobileLedgerProfile profile;
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_profile_detail);
+        Toolbar toolbar = findViewById(R.id.detail_toolbar);
+        setSupportActionBar(toolbar);
+
+        FloatingActionButton fab = findViewById(R.id.fab);
+        fab.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View view) {
+                Snackbar.make(view, "Replace with your own detail action", Snackbar.LENGTH_LONG)
+                        .setAction("Action", null).show();
+            }
+        });
+
+        // Show the Up button in the action bar.
+        ActionBar actionBar = getSupportActionBar();
+        if (actionBar != null) {
+            actionBar.setDisplayHomeAsUpEnabled(true);
+        }
+
+        // savedInstanceState is non-null when there is fragment state
+        // saved from previous configurations of this activity
+        // (e.g. when rotating the screen from portrait to landscape).
+        // In this case, the fragment will automatically be re-added
+        // to its container so we don't need to manually add it.
+        // For more information, see the Fragments API guide at:
+        //
+        // http://developer.android.com/guide/components/fragments.html
+        //
+        if (savedInstanceState == null) {
+            final int index = getIntent().getIntExtra(ProfileDetailFragment.ARG_ITEM_ID, -1);
+
+            if (index != -1) {
+                profile = Data.profiles.get(index);
+                if (profile == null) throw new AssertionError(
+                        String.format("Can't get profile " + "(index:%d) from the global list",
+                                index));
+            }
+
+            // Create the detail fragment and add it to the activity
+            // using a fragment transaction.
+            Bundle arguments = new Bundle();
+            arguments.putInt(ProfileDetailFragment.ARG_ITEM_ID, index);
+            ProfileDetailFragment fragment = new ProfileDetailFragment();
+            fragment.setArguments(arguments);
+            getSupportFragmentManager().beginTransaction()
+                    .add(R.id.profile_detail_container, fragment).commit();
+        }
+    }
+    @Override
+    public boolean onCreateOptionsMenu(Menu menu) {
+        super.onCreateOptionsMenu(menu);
+        Log.d("profiles", "[activity] Creating profile details options menu");
+        getMenuInflater().inflate(R.menu.profile_details, menu);
+        MenuItem menuDeleteProfile = menu.findItem(R.id.menuDelete);
+        menuDeleteProfile.setOnMenuItemClickListener(item -> {
+            Log.d("profiles", String.format("[activity] deleting profile %s", profile.getUuid()));
+            profile.removeFromDB();
+            Data.profiles.remove(profile);
+            if (Data.profile.get().equals(profile)) {
+                Log.d("profiles", "[activity] selecting profile 0");
+                Data.setCurrentProfile(Data.profiles.get(0));
+            }
+            finish();
+            return true;
+        });
+
+        menuDeleteProfile.setVisible((profile != null) && (Data.profiles.size() > 1));
+
+        return true;
+    }
+
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+        int id = item.getItemId();
+        if (id == android.R.id.home) {
+            // This ID represents the Home or Up button. In the case of this
+            // activity, the Up button is shown. For
+            // more details, see the Navigation pattern on Android Design:
+            //
+            // http://developer.android.com/design/patterns/navigation.html#up-vs-back
+            //
+            navigateUpTo(new Intent(this, ProfileListActivity.class));
+            return true;
+        }
+        return super.onOptionsItemSelected(item);
+    }
+}
diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfileDetailActivity.java
deleted file mode 100644 (file)
index 23d22f5..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright © 2019 Damyan Ivanov.
- * This file is part of MoLe.
- * MoLe is free software: you can distribute it and/or modify it
- * under the term of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your opinion), any later version.
- *
- * MoLe 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 terms for details.
- *
- * You should have received a copy of the GNU General Public License
- * along with MoLe. If not, see <https://www.gnu.org/licenses/>.
- */
-
-package net.ktnx.mobileledger.ui.profiles;
-
-import android.content.Intent;
-import android.os.Bundle;
-import android.support.design.widget.FloatingActionButton;
-import android.support.design.widget.Snackbar;
-import android.support.v7.app.ActionBar;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.Toolbar;
-import android.util.Log;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-
-import net.ktnx.mobileledger.R;
-import net.ktnx.mobileledger.model.Data;
-import net.ktnx.mobileledger.model.MobileLedgerProfile;
-import net.ktnx.mobileledger.ui.activity.ProfileListActivity;
-
-/**
- * An activity representing a single Profile detail screen. This
- * activity is only used on narrow width devices. On tablet-size devices,
- * item details are presented side-by-side with a list of items
- * in a {@link ProfileListActivity}.
- */
-public class ProfileDetailActivity extends AppCompatActivity {
-    private MobileLedgerProfile profile;
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.activity_profile_detail);
-        Toolbar toolbar = findViewById(R.id.detail_toolbar);
-        setSupportActionBar(toolbar);
-
-        FloatingActionButton fab = findViewById(R.id.fab);
-        fab.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View view) {
-                Snackbar.make(view, "Replace with your own detail action", Snackbar.LENGTH_LONG)
-                        .setAction("Action", null).show();
-            }
-        });
-
-        // Show the Up button in the action bar.
-        ActionBar actionBar = getSupportActionBar();
-        if (actionBar != null) {
-            actionBar.setDisplayHomeAsUpEnabled(true);
-        }
-
-        // savedInstanceState is non-null when there is fragment state
-        // saved from previous configurations of this activity
-        // (e.g. when rotating the screen from portrait to landscape).
-        // In this case, the fragment will automatically be re-added
-        // to its container so we don't need to manually add it.
-        // For more information, see the Fragments API guide at:
-        //
-        // http://developer.android.com/guide/components/fragments.html
-        //
-        if (savedInstanceState == null) {
-            final int index = getIntent().getIntExtra(ProfileDetailFragment.ARG_ITEM_ID, -1);
-
-            if (index != -1) {
-                profile = Data.profiles.get(index);
-                if (profile == null) throw new AssertionError(
-                        String.format("Can't get profile " + "(index:%d) from the global list",
-                                index));
-            }
-
-            // Create the detail fragment and add it to the activity
-            // using a fragment transaction.
-            Bundle arguments = new Bundle();
-            arguments.putInt(ProfileDetailFragment.ARG_ITEM_ID, index);
-            ProfileDetailFragment fragment = new ProfileDetailFragment();
-            fragment.setArguments(arguments);
-            getSupportFragmentManager().beginTransaction()
-                    .add(R.id.profile_detail_container, fragment).commit();
-        }
-    }
-    @Override
-    public boolean onCreateOptionsMenu(Menu menu) {
-        super.onCreateOptionsMenu(menu);
-        Log.d("profiles", "[activity] Creating profile details options menu");
-        getMenuInflater().inflate(R.menu.profile_details, menu);
-        MenuItem menuDeleteProfile = menu.findItem(R.id.menuDelete);
-        menuDeleteProfile.setOnMenuItemClickListener(item -> {
-            Log.d("profiles", String.format("[activity] deleting profile %s", profile.getUuid()));
-            profile.removeFromDB();
-            Data.profiles.remove(profile);
-            if (Data.profile.get().equals(profile)) {
-                Log.d("profiles", "[activity] selecting profile 0");
-                Data.setCurrentProfile(Data.profiles.get(0));
-            }
-            finish();
-            return true;
-        });
-
-        menuDeleteProfile.setVisible((profile != null) && (Data.profiles.size() > 1));
-
-        return true;
-    }
-
-    @Override
-    public boolean onOptionsItemSelected(MenuItem item) {
-        int id = item.getItemId();
-        if (id == android.R.id.home) {
-            // This ID represents the Home or Up button. In the case of this
-            // activity, the Up button is shown. For
-            // more details, see the Navigation pattern on Android Design:
-            //
-            // http://developer.android.com/design/patterns/navigation.html#up-vs-back
-            //
-            navigateUpTo(new Intent(this, ProfileListActivity.class));
-            return true;
-        }
-        return super.onOptionsItemSelected(item);
-    }
-}
index 15097e20b43c2d833666219ca863f9c38ed4cdc9..71376b93c7c30706526ba5be7ffa23692c0b7e92 100644 (file)
@@ -22,7 +22,7 @@
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:fitsSystemWindows="true"
-    tools:context=".ui.profiles.ProfileDetailActivity"
+    tools:context=".ui.activity.ProfileDetailActivity"
     tools:ignore="MergeRootFrame">
 
     <android.support.design.widget.AppBarLayout