Add UI for crypto wallet
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
/* Copyright (c) 2021 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.chromium.chrome.browser.crypto_wallet;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import org.chromium.chrome.R;
|
||||
|
||||
public class CardsFragment extends Fragment {
|
||||
|
||||
public static CardsFragment newInstance() {
|
||||
return new CardsFragment();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(
|
||||
@NonNull LayoutInflater inflater,
|
||||
@Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_cards, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
/* Copyright (c) 2021 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.chromium.chrome.browser.crypto_wallet;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import org.chromium.chrome.R;
|
||||
|
||||
// import com.github.mikephil.charting.charts.LineChart;
|
||||
// import com.github.mikephil.charting.components.LimitLine;
|
||||
// import com.github.mikephil.charting.components.XAxis;
|
||||
// import com.github.mikephil.charting.components.YAxis;
|
||||
// import com.github.mikephil.charting.data.Entry;
|
||||
// import com.github.mikephil.charting.data.LineData;
|
||||
// import com.github.mikephil.charting.data.LineDataSet;
|
||||
// import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class CryptoChildFragment extends Fragment {
|
||||
// private LineChart mChart;
|
||||
|
||||
public static CryptoChildFragment newInstance() {
|
||||
return new CryptoChildFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(
|
||||
@NonNull LayoutInflater inflater,
|
||||
@Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_crypto_child, container, false);
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
assert getActivity() != null;
|
||||
|
||||
// mChart = getActivity().findViewById(R.id.chart);
|
||||
// mChart.setTouchEnabled(true);
|
||||
// mChart.setPinchZoom(true);
|
||||
// mChart.getAxisLeft().setDrawAxisLine(false);
|
||||
// mChart.getXAxis().setDrawAxisLine(false);
|
||||
|
||||
// mChart.getDescription().setEnabled(false);
|
||||
// mChart.setDrawGridBackground(false);
|
||||
|
||||
// mChart.getXAxis().setDrawGridLines(false);
|
||||
// mChart.getAxisLeft().setDrawGridLines(false);
|
||||
// mChart.getAxisRight().setDrawGridLines(false);
|
||||
// mChart.getAxisRight().setDrawLimitLinesBehindData(false);
|
||||
// mChart.getAxisLeft().setDrawLabels(false);
|
||||
// mChart.getAxisRight().setDrawLabels(false);
|
||||
// mChart.getXAxis().setDrawLabels(false);
|
||||
// mChart.getXAxis().setDrawLimitLinesBehindData(false);
|
||||
// mChart.getLegend().setEnabled(false);
|
||||
|
||||
// renderData();
|
||||
|
||||
setUpCoinList(view);
|
||||
}
|
||||
|
||||
private void setUpCoinList(View view) {
|
||||
RecyclerView rvContacts = (RecyclerView) view.findViewById(R.id.rvCoins);
|
||||
// Create adapter passing in the sample user data
|
||||
WalletCoinAdapter walletCoinAdapter = new WalletCoinAdapter();
|
||||
// Attach the adapter to the recyclerview to populate items
|
||||
rvContacts.setAdapter(walletCoinAdapter);
|
||||
// Set layout manager to position the items
|
||||
rvContacts.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
|
||||
}
|
||||
|
||||
// public void renderData() {
|
||||
// LimitLine llXAxis = new LimitLine(10f, "Index 10");
|
||||
// llXAxis.setLineWidth(4f);
|
||||
// llXAxis.setTextSize(10f);
|
||||
|
||||
// XAxis xAxis = mChart.getXAxis();
|
||||
// xAxis.setAxisMaximum(10f);
|
||||
// xAxis.setAxisMinimum(0f);
|
||||
|
||||
// YAxis leftAxis = mChart.getAxisLeft();
|
||||
// leftAxis.removeAllLimitLines();
|
||||
// leftAxis.setAxisMaximum(350f);
|
||||
// leftAxis.setAxisMinimum(0f);
|
||||
|
||||
// mChart.getAxisRight().setEnabled(false);
|
||||
// setData();
|
||||
// }
|
||||
|
||||
// private void setData() {
|
||||
// assert getActivity() != null;
|
||||
// ArrayList<Entry> values = new ArrayList<>();
|
||||
// values.add(new Entry(1, 50));
|
||||
// values.add(new Entry(2, 100));
|
||||
// values.add(new Entry(3, 80));
|
||||
// values.add(new Entry(4, 120));
|
||||
// values.add(new Entry(5, 110));
|
||||
// values.add(new Entry(7, 150));
|
||||
// values.add(new Entry(8, 250));
|
||||
// values.add(new Entry(9, 190));
|
||||
|
||||
// LineDataSet set1;
|
||||
// if (mChart.getData() != null &&
|
||||
// mChart.getData().getDataSetCount() > 0) {
|
||||
// set1 = (LineDataSet) mChart.getData().getDataSetByIndex(0);
|
||||
// set1.setValues(values);
|
||||
// mChart.getData().notifyDataChanged();
|
||||
// mChart.notifyDataSetChanged();
|
||||
// } else {
|
||||
// set1 = new LineDataSet(values, "Sample Data");
|
||||
// set1.setColor(Color.DKGRAY);
|
||||
// set1.setCircleColor(Color.DKGRAY);
|
||||
|
||||
// Drawable drawable = ContextCompat.getDrawable(getActivity(), R.drawable.fade_blue);
|
||||
// set1.setFillDrawable(drawable);
|
||||
// ArrayList<ILineDataSet> dataSets = new ArrayList<>();
|
||||
// dataSets.add(set1);
|
||||
// LineData data = new LineData(dataSets);
|
||||
// mChart.setData(data);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/* Copyright (c) 2021 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.chromium.chrome.browser.crypto_wallet;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
|
||||
import org.chromium.chrome.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class CryptoFragment extends Fragment {
|
||||
private final List<String> titles = new ArrayList<>(Arrays.asList("PORTFOLIO", "NFTS", "INVEST", "LENDING", "APPS"));
|
||||
|
||||
public static CryptoFragment newInstance() {
|
||||
return new CryptoFragment();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(
|
||||
@NonNull LayoutInflater inflater,
|
||||
@Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_crypto, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
ViewPager viewPager = view.findViewById(R.id.view_pager);
|
||||
GooglePlusFragmentPageAdapter adapter =
|
||||
new GooglePlusFragmentPageAdapter(
|
||||
getChildFragmentManager());
|
||||
viewPager.setAdapter(adapter);
|
||||
viewPager.setOffscreenPageLimit(adapter.getCount() - 1);
|
||||
TabLayout tabLayout = view.findViewById(R.id.tabs);
|
||||
tabLayout.setupWithViewPager(viewPager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
private class GooglePlusFragmentPageAdapter extends FragmentPagerAdapter {
|
||||
|
||||
public GooglePlusFragmentPageAdapter(FragmentManager fm) {
|
||||
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
return CryptoChildFragment.newInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public CharSequence getPageTitle(int position) {
|
||||
return titles.get(position);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/* Copyright (c) 2021 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.chromium.chrome.browser.crypto_wallet;
|
||||
|
||||
import android.app.SearchManager;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.SearchView;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import org.chromium.chrome.R;
|
||||
|
||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||
|
||||
public class CryptoWalletActivity extends AppCompatActivity {
|
||||
|
||||
private BottomNavigationView navigation;
|
||||
private Toolbar toolbar;
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.wallet_search, menu);
|
||||
final MenuItem searchItem = menu.findItem(R.id.search);
|
||||
SearchView searchView = (SearchView) searchItem.getActionView();
|
||||
SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE);
|
||||
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_crypto_wallet);
|
||||
toolbar = findViewById(R.id.toolbar);
|
||||
toolbar.setTitleTextColor(getResources().getColor(android.R.color.black, null));
|
||||
toolbar.setOverflowIcon(ContextCompat.getDrawable(this, R.drawable.ic_baseline_more_vert_24));
|
||||
setSupportActionBar(toolbar);
|
||||
ViewPager viewPager = findViewById(R.id.view_pager);
|
||||
WalletNavigationFragmentPageAdapter adapter = new WalletNavigationFragmentPageAdapter(getSupportFragmentManager());
|
||||
viewPager.setAdapter(adapter);
|
||||
viewPager.setOffscreenPageLimit(adapter.getCount() - 1);
|
||||
navigation = findViewById(R.id.navigation);
|
||||
navigation.setOnNavigationItemSelectedListener(item -> {
|
||||
toolbar.setTitle(item.getTitle());
|
||||
int itemId = item.getItemId();
|
||||
if (itemId == R.id.navigation_crypto) {
|
||||
viewPager.setCurrentItem(0);
|
||||
initTitle(0);
|
||||
return true;
|
||||
} else if (itemId == R.id.navigation_rewards) {
|
||||
viewPager.setCurrentItem(1);
|
||||
initTitle(1);
|
||||
return true;
|
||||
} else if (itemId == R.id.navigation_swap) {
|
||||
viewPager.setCurrentItem(2);
|
||||
initTitle(2);
|
||||
return true;
|
||||
} else if (itemId == R.id.navigation_cards) {
|
||||
viewPager.setCurrentItem(3);
|
||||
initTitle(3);
|
||||
return true;
|
||||
} else if (itemId == R.id.navigation_lock) {
|
||||
viewPager.setCurrentItem(4);
|
||||
initTitle(4);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
initTitle(0);
|
||||
}
|
||||
|
||||
private void initTitle(int position) {
|
||||
toolbar.post(() -> toolbar.setTitle(String.format(getResources().getString(R.string.my), navigation.getMenu().getItem(position).getTitle())));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/* Copyright (c) 2021 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.chromium.chrome.browser.crypto_wallet;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import org.chromium.chrome.R;
|
||||
|
||||
public class RewardsFragment extends Fragment {
|
||||
|
||||
private static final String ARG_ID = "arg_id";
|
||||
|
||||
public static RewardsFragment newInstance() {
|
||||
return new RewardsFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(
|
||||
@NonNull LayoutInflater inflater,
|
||||
@Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_rewards, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/* Copyright (c) 2021 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.chromium.chrome.browser.crypto_wallet;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import org.chromium.chrome.R;
|
||||
|
||||
public class WalletCoinAdapter extends
|
||||
RecyclerView.Adapter<WalletCoinAdapter.ViewHolder> {
|
||||
|
||||
@Override
|
||||
public @NonNull
|
||||
WalletCoinAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
Context context = parent.getContext();
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
View walletCoinView = inflater.inflate(R.layout.wallet_coin_list_item, parent, false);
|
||||
return new ViewHolder(walletCoinView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull WalletCoinAdapter.ViewHolder holder, int position) {
|
||||
//TODO add holder view
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
public ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/* Copyright (c) 2021 The Brave Authors. All rights reserved.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.chromium.chrome.browser.crypto_wallet;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
|
||||
import org.chromium.chrome.R;
|
||||
|
||||
class WalletNavigationFragmentPageAdapter extends FragmentPagerAdapter {
|
||||
|
||||
public WalletNavigationFragmentPageAdapter(FragmentManager fm) {
|
||||
super(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
switch (position) {
|
||||
case 0:
|
||||
return CryptoFragment.newInstance();
|
||||
case 1:
|
||||
return RewardsFragment.newInstance();
|
||||
case 2:
|
||||
return CardsFragment.newInstance();
|
||||
case 3:
|
||||
return CardsFragment.newInstance();
|
||||
case 4:
|
||||
return CardsFragment.newInstance();
|
||||
default:
|
||||
throw new RuntimeException("Not supported");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return 5;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user