@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); android.view.MenuInflater inflater = getMenuInflater(); // Rinomina nodo e scelta icona inflater.inflate(R.menu.scenes_ctx_menu, menu); super.onCreateContextMenu(menu, v, menuInfo); }
@Override protected void onStart() { super.onStart(); setActionBarInfo(getString(R.string.scenes_title)); this.getSupportActionBar().setDisplayHomeAsUpEnabled(true); opzioni.initializePrefs(); if (!opzioni.isDbConfigured()) { AlertDialogHelper.dbNotInitedDialog(this); } SoulissDBHelper.open(); // prendo comandi dal DB, setto adapter LinkedList<SoulissScene> goer = datasource.getScenes(SoulissClient.getAppContext()); scenesArray = new SoulissScene[goer.size()]; scenesArray = goer.toArray(scenesArray); progsAdapter = new SceneListAdapter(this, scenesArray, opzioni); // Adapter della lista listaScenesView.setAdapter(progsAdapter); listaScenesView.invalidateViews(); // ImageView nodeic = (ImageView) findViewById(R.id.scene_icon); // nodeic.setAlpha(150); mAdapter = new NavDrawerAdapter( SceneListActivity.this, R.layout.drawer_list_item, dmh.getStuff(), DrawerMenuHelper.SCENES); mDrawerList.setAdapter(mAdapter); }
@Override protected void onResume() { super.onResume(); IntentFilter filtere = new IntentFilter(); filtere.addAction("it.angelic.soulissclient.GOT_DATA"); registerReceiver(datareceiver, filtere); }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { Log.d(TAG, "new command created, resultCode = " + resultCode); super.onActivityResult(requestCode, resultCode, data); if (data != null) { int msg = data.getIntExtra("returnedData", -1); if (resultCode == RESULT_OK && requestCode == 12) { switch (msg) { case Constants.COMMAND_TIMED: Toast.makeText(this, getString(R.string.command_inserted), Toast.LENGTH_SHORT).show(); break; case Constants.COMMAND_COMEBACK_CODE: // fall throught case Constants.COMMAND_GOAWAY_CODE: Toast.makeText(this, getString(R.string.command_inserted), Toast.LENGTH_SHORT).show(); break; case Constants.COMMAND_TRIGGERED: Toast.makeText(this, getString(R.string.command_inserted), Toast.LENGTH_SHORT).show(); break; default: Toast.makeText(this, getString(R.string.command_inserted_fail), Toast.LENGTH_LONG) .show(); break; } } else { Toast.makeText(this, getString(R.string.command_inserted_fail), Toast.LENGTH_LONG).show(); } } }
@Override public void onCreate(Bundle savedInstanceState) { opzioni = SoulissApp.getOpzioni(); getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS); if (opzioni.isLightThemeSelected()) setTheme(R.style.LightThemeSelector); else setTheme(R.style.DarkThemeSelector); super.onCreate(savedInstanceState); setContentView(R.layout.main_programs); setTitle(getString(R.string.app_name) + " - " + getString(R.string.programs_title)); tt = (TextView) findViewById(R.id.TextViewTypicals); listaProgrammiView = (ListView) findViewById(R.id.ListViewListaProgs); SoulissApp.setBackground(findViewById(R.id.containerlistaProgrammi), getWindowManager()); // check se IP non settato if (!opzioni.isSoulissIpConfigured() && !opzioni.isSoulissReachable()) { AlertDialog.Builder alert = AlertDialogHelper.sysNotInitedDialog(this); alert.show(); } datasource = new SoulissDBHelper(this); super.initDrawer(this, DrawerMenuHelper.PROGRAMS); listaProgrammiView.setOnItemClickListener( new OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Log.w(TAG, "Activating SCENE " + arg2); Intent nodeDatail = new Intent(ProgramListActivity.this, AddProgramActivity.class); nodeDatail.putExtra("PROG", programsArray[arg2]); ProgramListActivity.this.startActivity(nodeDatail); if (opzioni.isAnimationsEnabled()) overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left); } }); registerForContextMenu(listaProgrammiView); SoulissApp.setBackground(findViewById(R.id.containerlistaScenes), getWindowManager()); }
@Override public void onBackPressed() { Fragment details = getSupportFragmentManager().findFragmentById(R.id.detailPane); Log.w(Constants.TAG, "instanceof: " + details.getClass()); if (details instanceof TagDetailFragment) { supportFinishAfterTransition(); super.onBackPressed(); } else { getSupportFragmentManager().popBackStack(); setActionBarInfo(collected.getNiceName()); // don't call super here } }
@Override protected void onStart() { super.onStart(); setActionBarInfo(getString(R.string.tag)); opzioni.initializePrefs(); if (!opzioni.isDbConfigured()) { AlertDialogHelper.dbNotInitedDialog(this); } SoulissDBHelper.open(); this.getSupportActionBar().setDisplayHomeAsUpEnabled(true); navAdapter = new NavDrawerAdapter( TagGridActivity.this, R.layout.drawer_list_item, dmh.getStuff(), DrawerMenuHelper.TAGS); mDrawerList.setAdapter(navAdapter); }
@Override protected void onCreate(Bundle savedInstanceState) { opzioni = SoulissApp.getOpzioni(); db = new SoulissDBTagHelper(this); if (opzioni.isLightThemeSelected()) setTheme(R.style.LightThemeSelector); else setTheme(R.style.DarkThemeSelector); super.onCreate(savedInstanceState); setContentView(R.layout.main_tag_detail); Bundle extras = getIntent().getExtras(); if (extras != null && extras.get("TAG") != null) tagId = (long) extras.get("TAG"); try { collected = db.getTag((int) tagId); } catch (SQLDataException sql) { Log.i(Constants.TAG, "TAGID NOT FOUND: " + tagId); } if (savedInstanceState == null) { FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); fragment = new TagDetailFragment(); transaction.replace(R.id.detailPane, fragment); transaction.commit(); } /* try { setEnterSharedElementCallback(new SharedElementCallback() { @Override public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) { Log.i(Constants.TAG, "EnterSharedElement.onMapSharedElements:" + sharedElements.size()); //manual override perche il fragment ancora non c'e //sharedElements.put("photo_hero", fragment.getView().findViewById(R.id.photo)); // sharedElements.put("shadow_hero", fragment.getView().findViewById(R.id.infoAlpha)); // sharedElements.put("tag_icon", fragment.getView().findViewById(R.id.imageTagIcon)); super.onMapSharedElements(names, sharedElements); } @Override public void onRejectSharedElements(List<View> rejectedSharedElements) { Log.i(Constants.TAG, "EnterSharedElement.onMapSharedElements:" + rejectedSharedElements.size()); super.onRejectSharedElements(rejectedSharedElements); } }); } catch (Exception uie) { Log.e(Constants.TAG, "UIE:" + uie.getMessage()); }*/ }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) { super.onActivityResult(requestCode, resultCode, imageReturnedIntent); Log.i(Constants.TAG, "SAVED IMG RESULT:" + resultCode); if (resultCode == RESULT_OK) { Uri selectedImage = imageReturnedIntent.getData(); Log.i(Constants.TAG, "SAVED IMG PATH:" + selectedImage.toString()); tags[requestCode].setImagePath(selectedImage.toString()); // String[] filePathColumn = {MediaStore.Images.Media.DATA}; datasource.createOrUpdateTag(tags[requestCode]); // Bitmap yourSelectedImage = BitmapFactory.decodeFile(filePath); Log.i(Constants.TAG, "SAVED IMG PATH:" + tags[requestCode].getImagePath()); tagAdapter.notifyItemChanged(requestCode); } }
@Override protected void onStart() { super.onStart(); setActionBarInfo(getString(R.string.programs_title)); this.getSupportActionBar().setDisplayHomeAsUpEnabled(true); SoulissDBHelper.open(); opzioni.initializePrefs(); if (!opzioni.isDbConfigured()) { AlertDialogHelper.dbNotInitedDialog(this); } if (!opzioni.isDataServiceEnabled()) { AlertDialogHelper.serviceNotActiveDialog(this); } // prendo comandi dal DB, setto adapter LinkedList<SoulissCommand> goer = datasource.getUnexecutedCommands(this); if (goer.size() == 0) tt.setText(getString(R.string.programs_no)); programsArray = new SoulissCommand[goer.size()]; programsArray = goer.toArray(programsArray); progsAdapter = new ProgramListAdapter( this.getApplicationContext(), programsArray, datasource.getTriggerMap(this), opzioni); // Adapter della lista listaProgrammiView.setAdapter(progsAdapter); listaProgrammiView.invalidateViews(); // forza refresh drawer mDrawermAdapter = new NavDrawerAdapter( ProgramListActivity.this, R.layout.drawer_list_item, dmh.getStuff(), DrawerMenuHelper.PROGRAMS); mDrawerList.setAdapter(mDrawermAdapter); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.attachToListView(listaProgrammiView); // ADD NEW PROGRAM Listener fab.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { Intent myIntentt = new Intent(ProgramListActivity.this, AddProgramActivity.class); ProgramListActivity.this.startActivityForResult(myIntentt, 12); } }); }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) { super.onActivityResult(requestCode, resultCode, imageReturnedIntent); Log.i(Constants.TAG, "SAVING IMG RESULT:" + resultCode); if (resultCode == RESULT_OK) { Uri selectedImage = imageReturnedIntent.getData(); Log.i(Constants.TAG, "RESULT_OK PATH:" + selectedImage.toString()); collected.setImagePath(selectedImage.toString()); // String[] filePathColumn = {MediaStore.Images.Media.DATA}; db.createOrUpdateTag(collected); // Bitmap yourSelectedImage = BitmapFactory.decodeFile(filePath); Log.i(Constants.TAG, "SAVED IMG PATH:" + collected.getImagePath()); } FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); TagDetailFragment fragment = new TagDetailFragment(); transaction.replace(R.id.detailPane, fragment); transaction.commit(); }
@Override public void onCreate(Bundle savedInstanceState) { opzioni = SoulissClient.getOpzioni(); // Remove title bar // this.requestWindowFeature(Window.FEATURE_NO_TITLE); if (opzioni.isLightThemeSelected()) setTheme(R.style.LightThemeSelector); else setTheme(R.style.DarkThemeSelector); super.onCreate(savedInstanceState); setContentView(R.layout.main_scenes); // final Button buttAddProgram = (Button) // findViewById(R.id.buttonAddScene); // tt = (TextView) findViewById(R.id.TextViewScenes); /* * if ("def".compareToIgnoreCase(opzioni.getPrefFont()) != 0) { Typeface * font = Typeface.createFromAsset(getAssets(), opzioni.getPrefFont()); * tt.setTypeface(font, Typeface.NORMAL); } */ // ParallaxListView listView2 = (ParallaxListView) findViewById(R.id.paraList); listaScenesView = (ListView) findViewById(R.id.ListViewListaScenes); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.attachToListView(listaScenesView); SoulissClient.setBackground(findViewById(R.id.containerlistaScenes), getWindowManager()); // ADD NEW SCENE fab.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { int rest = datasource.createOrUpdateScene(null); // prendo comandi dal DB, setto adapter LinkedList<SoulissScene> goer = datasource.getScenes(SoulissClient.getAppContext()); // scenesArray = new SoulissScene[goer.size()]; scenesArray = goer.toArray(scenesArray); progsAdapter = new SceneListAdapter(SceneListActivity.this, scenesArray, opzioni); // Adapter della lista // SceneListAdapter t = listaScenesView.getAdapter(); progsAdapter.setScenes(scenesArray); progsAdapter.notifyDataSetChanged(); listaScenesView.setAdapter(progsAdapter); listaScenesView.invalidateViews(); Toast.makeText( SceneListActivity.this, "Scene " + rest + " inserted, long-press to rename it and choose icon", Toast.LENGTH_LONG) .show(); } }); // check se IP non settato if (!opzioni.isSoulissIpConfigured() && !opzioni.isSoulissReachable()) { AlertDialog.Builder alert = AlertDialogHelper.sysNotInitedDialog(this); alert.show(); } // TODO error management datasource = new SoulissDBHelper(this); // datasource.open(); // DRAWER super.initDrawer(this, DrawerMenuHelper.SCENES); listaScenesView.setOnItemClickListener( new OnItemClickListener() { public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { Log.w(TAG, "Activating SCENE " + arg2); Intent nodeDatail = new Intent(SceneListActivity.this, SceneDetailActivity.class); SceneViewHolder holder = (SceneViewHolder) arg1.getTag(); nodeDatail.putExtra("SCENA", holder.data); SceneListActivity.this.startActivity(nodeDatail); if (opzioni.isAnimationsEnabled()) overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left); } }); registerForContextMenu(listaScenesView); }
@Override protected void onDestroy() { super.onDestroy(); }
@Override public void onConfigurationChanged(Configuration newConfig) { // ignore orientation change super.onConfigurationChanged(newConfig); mDrawerToggle.onConfigurationChanged(newConfig); }
@Override protected void onPause() { super.onPause(); unregisterReceiver(datareceiver); }
@Override protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); // Sync the toggle state after onRestoreInstanceState has occurred. mDrawerToggle.syncState(); }
@Override public void onCreate(Bundle savedInstanceState) { opzioni = SoulissApp.getOpzioni(); // Remove title bar // this.requestWindowFeature(Window.FEATURE_NO_TITLE); if (opzioni.isLightThemeSelected()) setTheme(R.style.LightThemeSelector); else setTheme(R.style.DarkThemeSelector); super.onCreate(savedInstanceState); setContentView(R.layout.main_tags_grid); // final Button buttAddProgram = (Button) // findViewById(R.id.buttonAddScene); // tt = (TextView) findViewById(R.id.TextViewScenes); /* * if ("def".compareToIgnoreCase(opzioni.getPrefFont()) != 0) { Typeface * font = Typeface.createFromAsset(getAssets(), opzioni.getPrefFont()); * tt.setTypeface(font, Typeface.NORMAL); } */ mRecyclerView = (ContextMenuRecyclerView) findViewById(R.id.recyclerViewTags); // 3 colonne in horiz gridManager = new GridLayoutManager( this, getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 3 : 2); mRecyclerView.setLayoutManager(gridManager); mRecyclerView.setItemAnimator(new DefaultItemAnimator()); // FIXME // Floatin Button FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.attachToRecyclerView(mRecyclerView); // ADD NEW SCENE fab.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // LinkedList perche asList torna array non ridimensionabile List<SoulissTag> goerBck = new LinkedList<>(Arrays.asList(tagAdapter.getTagArray())); long rest = datasource.createOrUpdateTag(null); // prendo comandi dal DB, setto adapter List<SoulissTag> goer = datasource.getTags(SoulissApp.getAppContext()); goer.removeAll(goerBck); Assert.assertTrue(goer.size() == 1); SoulissTag newTag = goer.get(0); // quello nuovo goerBck.add(Constants.TAG_INSERT_POINT, newTag); // goer.removeAll(goerBck); tags = new SoulissTag[goerBck.size()]; tags = goerBck.toArray(tags); // tagAdapter = new TagListAdapter(TagGridActivity.this, tags, opzioni); // Adapter della lista // SceneListAdapter t = listaTagsView.getAdapter(); tagAdapter.setTagArray(tags); tagAdapter.notifyItemInserted(Constants.TAG_INSERT_POINT); Handler handler = new Handler(); handler.postDelayed( new Runnable() { // fai finire l'animazione public void run() { // force rebind of click listeners tagAdapter.notifyDataSetChanged(); } }, 500); // msec // listaTagsView.invalidateViews(); Toast.makeText( TagGridActivity.this, getString(R.string.tag) + rest + " inserted, long-press to rename it and choose icon", Toast.LENGTH_LONG) .show(); } }); // check se IP non settato if (!opzioni.isSoulissIpConfigured() && !opzioni.isSoulissReachable()) { AlertDialog.Builder alert = AlertDialogHelper.sysNotInitedDialog(this); alert.show(); } datasource = new SoulissDBTagHelper(this); SoulissDBHelper.open(); // prendo comandi dal DB, setto adapter List<SoulissTag> goer = datasource.getTags(SoulissApp.getAppContext()); tags = new SoulissTag[goer.size()]; tags = goer.toArray(tags); tagAdapter = new TagRecyclerAdapter(this, tags, opzioni); // Adapter della lista mRecyclerView.setAdapter(tagAdapter); // DRAWER super.initDrawer(this, DrawerMenuHelper.TAGS); registerForContextMenu(mRecyclerView); // TODEBUG TRANSACTIONS setExitSharedElementCallback( new SharedElementCallback() { @Override public void onSharedElementStart( List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) { Log.d( Constants.TAG, "ExitSharedElementCallback.onSharedElementStart:" + sharedElementNames.size()); super.onSharedElementStart(sharedElementNames, sharedElements, sharedElementSnapshots); } @Override public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) { Log.d(Constants.TAG, "ExitSharedElementCallback.onMapSharedElements:" + names.get(0)); super.onMapSharedElements(names, sharedElements); } @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void onRejectSharedElements(List<View> rejectedSharedElements) { Log.d( Constants.TAG, "ExitSharedElementCallback.onRejectSharedElements:" + rejectedSharedElements.size()); super.onRejectSharedElements(rejectedSharedElements); } @Override public void onSharedElementEnd( List<String> sharedElementNames, List<View> sharedElements, List<View> sharedElementSnapshots) { Log.i(Constants.TAG, "ExitSharedElementCallback.onSharedElementEnd"); super.onSharedElementEnd(sharedElementNames, sharedElements, sharedElementSnapshots); } }); }
@Override protected void onResume() { super.onResume(); setActionBarInfo(collected.getNiceName()); }
@Override protected void onDestroy() { super.onDestroy(); datasource.close(); }