]> git.ktnx.net Git - mobile-ledger.git/blob - app/src/main/java/net/ktnx/mobileledger/ui/activity/ProfileDetailActivity.java
remove unused reference to the profile detail FAB
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / activity / ProfileDetailActivity.java
1 /*
2  * Copyright © 2019 Damyan Ivanov.
3  * This file is part of MoLe.
4  * MoLe is free software: you can distribute it and/or modify it
5  * under the term of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your opinion), any later version.
8  *
9  * MoLe is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License terms for details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with MoLe. If not, see <https://www.gnu.org/licenses/>.
16  */
17
18 package net.ktnx.mobileledger.ui.activity;
19
20 import android.os.Bundle;
21 import android.util.Log;
22 import android.view.Menu;
23
24 import net.ktnx.mobileledger.R;
25 import net.ktnx.mobileledger.model.Data;
26 import net.ktnx.mobileledger.model.MobileLedgerProfile;
27 import net.ktnx.mobileledger.ui.profiles.ProfileDetailFragment;
28 import net.ktnx.mobileledger.utils.Colors;
29
30 import androidx.appcompat.app.ActionBar;
31 import androidx.appcompat.widget.Toolbar;
32
33 /**
34  * An activity representing a single Profile detail screen. This
35  * activity is only used on narrow width devices. On tablet-size devices,
36  * item details are presented side-by-side with a list of items
37  * in a ProfileListActivity (not really).
38  */
39 public class ProfileDetailActivity extends CrashReportingActivity {
40     private MobileLedgerProfile profile = null;
41     private ProfileDetailFragment mFragment;
42     @Override
43     protected void onCreate(Bundle savedInstanceState) {
44         final int index = getIntent().getIntExtra(ProfileDetailFragment.ARG_ITEM_ID, -1);
45
46         if (index != -1) {
47             profile = Data.profiles.get(index);
48             if (profile == null) throw new AssertionError(
49                     String.format("Can't get profile " + "(index:%d) from the global list", index));
50
51             Log.d("profiles", String.format("Editing profile %s (%s); hue=%d", profile.getName(),
52                     profile.getUuid(), profile.getThemeId()));
53         }
54
55         super.onCreate(savedInstanceState);
56         Colors.setupTheme(this, profile);
57         setContentView(R.layout.activity_profile_detail);
58         Toolbar toolbar = findViewById(R.id.detail_toolbar);
59         setSupportActionBar(toolbar);
60
61         // Show the Up button in the action bar.
62         ActionBar actionBar = getSupportActionBar();
63         if (actionBar != null) {
64             actionBar.setDisplayHomeAsUpEnabled(true);
65         }
66
67         // savedInstanceState is non-null when there is fragment state
68         // saved from previous configurations of this activity
69         // (e.g. when rotating the screen from portrait to landscape).
70         // In this case, the fragment will automatically be re-added
71         // to its container so we don't need to manually add it.
72         // For more information, see the Fragments API guide at:
73         //
74         // http://developer.android.com/guide/components/fragments.html
75         //
76         if (savedInstanceState == null) {
77             // Create the detail fragment and add it to the activity
78             // using a fragment transaction.
79             Bundle arguments = new Bundle();
80             arguments.putInt(ProfileDetailFragment.ARG_ITEM_ID, index);
81             mFragment = new ProfileDetailFragment();
82             mFragment.setArguments(arguments);
83             getSupportFragmentManager().beginTransaction()
84                     .add(R.id.profile_detail_container, mFragment).commit();
85         }
86     }
87     @Override
88     public boolean onCreateOptionsMenu(Menu menu) {
89         super.onCreateOptionsMenu(menu);
90         Log.d("profiles", "[activity] Creating profile details options menu");
91         mFragment.onCreateOptionsMenu(menu, getMenuInflater());
92
93         return true;
94     }
95
96 }