use of com.genonbeta.TrebleShot.widget.PowerfulActionMode in project TrebleShot by genonbeta.
the class TransactionActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_transaction);
mDatabase = new AccessDatabase(this);
mTransactionFragment = (TransactionListFragment) getSupportFragmentManager().findFragmentById(R.id.activity_transaction_listfragment_transaction);
mPathView = findViewById(R.id.activity_transaction_explorer_recycler);
mHomeButton = findViewById(R.id.activity_transaction_explorer_image_home);
mPowafulActionMode = findViewById(R.id.activity_transaction_action_mode);
// mPowafulActionMode.setContainerLayout(findViewById(R.id.activity_transaction_action_mode_container));
final Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
mDrawerLayout = findViewById(R.id.drawer_layout);
if (mDrawerLayout != null) {
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.text_navigationDrawerOpen, R.string.text_navigationDrawerClose);
mDrawerLayout.addDrawerListener(toggle);
toggle.syncState();
}
mNavigationView = findViewById(R.id.nav_view);
mNavigationView.setNavigationItemSelectedListener(this);
mPathView.setHasFixedSize(true);
mFilter.addAction(AccessDatabase.ACTION_DATABASE_CHANGE);
mLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
mPathAdapter = new TransactionPathResolverRecyclerAdapter();
mPathView.setLayoutManager(mLayoutManager);
mLayoutManager.setStackFromEnd(true);
mPathView.setAdapter(mPathAdapter);
mPowafulActionMode.setOnSelectionTaskListener(new PowerfulActionMode.OnSelectionTaskListener() {
@Override
public void onSelectionTask(boolean started, PowerfulActionMode actionMode) {
toolbar.setVisibility(!started ? View.VISIBLE : View.GONE);
}
});
mPathAdapter.setOnClickListener(new PathResolverRecyclerAdapter.OnClickListener<String>() {
@Override
public void onClick(PathResolverRecyclerAdapter.Holder<String> holder) {
goPath(holder.index.object);
}
});
mHomeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
goPath(null);
}
});
if (ACTION_LIST_TRANSFERS.equals(getIntent().getAction()) && getIntent().hasExtra(EXTRA_GROUP_ID)) {
TransactionObject.Group group = new TransactionObject.Group(getIntent().getIntExtra(EXTRA_GROUP_ID, -1));
try {
mDatabase.reconstruct(group);
NetworkDevice networkDevice = new NetworkDevice(group.deviceId);
mDatabase.reconstruct(networkDevice);
mGroup = group;
mDevice = networkDevice;
mInfoDialog = new TransactionGroupInfoDialog(this, mDatabase, mGroup);
if (getSupportActionBar() != null)
getSupportActionBar().setTitle(mDevice.nickname);
mTransactionFragment.getAdapter().setPathChangedListener(this);
applyPath(null);
View headerView = mNavigationView.getHeaderView(0);
View layoutView = headerView.findViewById(R.id.header_default_device_container);
ImageView imageView = headerView.findViewById(R.id.header_default_device_image);
TextView deviceNameText = headerView.findViewById(R.id.header_default_device_name_text);
TextView versionText = headerView.findViewById(R.id.header_default_device_version_text);
String firstLetters = TextUtils.getFirstLetters(mDevice.nickname, 1);
TextDrawable drawable = TextDrawable.builder().buildRoundRect(firstLetters.length() > 0 ? firstLetters : "?", ContextCompat.getColor(getApplicationContext(), R.color.networkDeviceRipple), 100);
layoutView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new DeviceInfoDialog(TransactionActivity.this, mDatabase, mDevice).show();
if (mDrawerLayout != null)
mDrawerLayout.closeDrawer(Gravity.START);
}
});
imageView.setImageDrawable(drawable);
deviceNameText.setText(mDevice.nickname);
versionText.setText(mDevice.versionName);
} catch (Exception e) {
e.printStackTrace();
}
}
if (mGroup == null)
finish();
}
use of com.genonbeta.TrebleShot.widget.PowerfulActionMode in project TrebleShot by genonbeta.
the class HomeActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
mDrawerLayout = findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, R.string.text_navigationDrawerOpen, R.string.text_navigationDrawerClose);
mDrawerLayout.addDrawerListener(toggle);
toggle.syncState();
mUpdater = new GitHubUpdater(this, AppConfig.URI_REPO_APP_UPDATE, R.style.AppTheme);
mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
mActionMode = findViewById(R.id.content_powerful_action_mode);
mNavigationView = findViewById(R.id.nav_view);
mFAB = findViewById(R.id.content_fab);
mNavigationView.setNavigationItemSelectedListener(this);
mFragmentDeviceList = Fragment.instantiate(this, NetworkDeviceListFragment.class.getName());
mFragmentFileExplorer = Fragment.instantiate(this, FileExplorerFragment.class.getName());
mFragmentTransactions = Fragment.instantiate(this, TransactionGroupListFragment.class.getName());
mFragmentShareApp = Fragment.instantiate(this, ApplicationListFragment.class.getName());
mFragmentShareImage = Fragment.instantiate(this, ImageListFragment.class.getName());
mFragmentShareMusic = Fragment.instantiate(this, MusicListFragment.class.getName());
mFragmentShareVideo = Fragment.instantiate(this, VideoListFragment.class.getName());
mFragmentShareText = Fragment.instantiate(this, TextStreamListFragment.class.getName());
mActionMode.setOnSelectionTaskListener(new PowerfulActionMode.OnSelectionTaskListener() {
@Override
public void onSelectionTask(boolean started, PowerfulActionMode actionMode) {
toolbar.setVisibility(!started ? View.VISIBLE : View.GONE);
}
});
if (mPreferences.contains("availableVersion") && mUpdater.isNewVersion(mPreferences.getString("availableVersion", null))) {
highlightUpdater(mPreferences.getString("availableVersion", null));
} else {
mUpdater.checkForUpdates(false, new GitHubUpdater.OnInfoAvailableListener() {
@Override
public void onInfoAvailable(boolean newVersion, String versionName, String title, String description, String releaseDate) {
mPreferences.edit().putString("availableVersion", versionName).apply();
if (newVersion)
highlightUpdater(versionName);
}
});
}
NetworkDevice localDevice = AppUtils.getLocalDevice(getApplicationContext());
if (mPreferences.getInt("migrated_version", localDevice.versionNumber) < localDevice.versionNumber) {
// migrating to a new version
}
mPreferences.edit().putInt("migrated_version", localDevice.versionNumber).apply();
if (!checkRequestedFragment(getIntent()) && !restorePreviousFragment()) {
changeFragment(mFragmentDeviceList);
mNavigationView.setCheckedItem(R.id.menu_activity_main_device_list);
}
}
Aggregations