List of usage examples for android.widget LinearLayout setVisibility
@RemotableViewMethod public void setVisibility(@Visibility int visibility)
From source file:com.facebook.samples.loginsample.accountkit.AccountKitLoginActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.account_kit_activity); if (AccountKit.getCurrentAccessToken() != null) { showHelloActivity(null);/* w w w. j a va 2 s.c o m*/ } final Spinner themeSpinner = (Spinner) findViewById(R.id.theme_spinner); if (themeSpinner != null) { final ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.theme_options, android.R.layout.simple_spinner_dropdown_item); themeSpinner.setAdapter(adapter); themeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(final AdapterView<?> parent, final View view, final int position, final long id) { switch (position) { case 0: selectedThemeId = R.style.AppLoginTheme; break; case 1: selectedThemeId = R.style.AppLoginTheme_Salmon; break; case 2: selectedThemeId = R.style.AppLoginTheme_Yellow; break; case 3: selectedThemeId = R.style.AppLoginTheme_Red; break; case 4: selectedThemeId = R.style.AppLoginTheme_Dog; break; case 5: selectedThemeId = R.style.AppLoginTheme_Bicycle; break; case 6: selectedThemeId = R.style.AppLoginTheme_Reverb_A; advancedUISwitch.setChecked(true); break; case 7: selectedThemeId = R.style.AppLoginTheme_Reverb_B; advancedUISwitch.setChecked(true); break; case 8: selectedThemeId = R.style.AppLoginTheme_Reverb_C; advancedUISwitch.setChecked(true); break; default: selectedThemeId = -1; break; } } @Override public void onNothingSelected(final AdapterView<?> parent) { selectedThemeId = -1; } }); } advancedUISwitch = (Switch) findViewById(R.id.advanced_ui_switch); final AccountKitLoginActivity thisActivity = this; final LinearLayout advancedUIOptionsLayout = (LinearLayout) findViewById(R.id.advanced_ui_options); final List<CharSequence> buttonNames = new ArrayList<>(); buttonNames.add("Default"); for (ButtonType buttonType : ButtonType.values()) { buttonNames.add(buttonType.name()); } final ArrayAdapter<CharSequence> buttonNameAdapter = new ArrayAdapter<>(thisActivity, android.R.layout.simple_spinner_dropdown_item, buttonNames); advancedUISwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { advancedUIOptionsLayout.setVisibility(View.VISIBLE); final Spinner entryButtonSpinner = (Spinner) findViewById(R.id.entry_button_spinner); if (entryButtonSpinner != null) { entryButtonSpinner.setAdapter(buttonNameAdapter); entryButtonSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(final AdapterView<?> parent, final View view, final int position, final long id) { // First position is empty, so anything past that if (position > 0) { entryButton = ButtonType .valueOf(entryButtonSpinner.getSelectedItem().toString()); } else { entryButton = null; } } @Override public void onNothingSelected(final AdapterView<?> parent) { entryButton = null; } }); } final Spinner confirmButtonSpinner = (Spinner) findViewById(R.id.confirm_button_spinner); if (confirmButtonSpinner != null) { confirmButtonSpinner.setAdapter(buttonNameAdapter); confirmButtonSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(final AdapterView<?> parent, final View view, final int position, final long id) { // First position is empty, so anything past // that if (position > 0) { confirmButton = ButtonType .valueOf(confirmButtonSpinner.getSelectedItem().toString()); } else { confirmButton = null; } } @Override public void onNothingSelected(final AdapterView<?> parent) { confirmButton = null; } }); } final Spinner textPositionSpinner = (Spinner) findViewById(R.id.text_position_spinner); if (textPositionSpinner != null) { final List<CharSequence> textPositions = new ArrayList<>(); textPositions.add("Default"); for (TextPosition textPosition : TextPosition.values()) { textPositions.add(textPosition.name()); } final ArrayAdapter<CharSequence> textPositionAdapter = new ArrayAdapter<>(thisActivity, android.R.layout.simple_spinner_dropdown_item, textPositions); textPositionSpinner.setAdapter(textPositionAdapter); textPositionSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(final AdapterView<?> parent, final View view, final int position, final long id) { // First position is empty, so anything past // that if (position > 0) { textPosition = TextPosition .valueOf(textPositionSpinner.getSelectedItem().toString()); } else { textPosition = null; } } @Override public void onNothingSelected(final AdapterView<?> parent) { textPosition = null; } }); } } else if (isReverbThemeSelected()) { advancedUISwitch.setChecked(true); Toast.makeText(AccountKitLoginActivity.this, R.string.reverb_advanced_ui_required, Toast.LENGTH_LONG).show(); } else { advancedUIOptionsLayout.setVisibility(View.GONE); } } }); }
From source file:org.ounl.lifelonglearninghub.learntracker.gis.ou.swipe.TimeLineActivity.java
/** * On click image view to start stop recording * //from w w w . j ava 2 s. c o m * Records time SYNCHRONOUSLY * * @param v */ public void onClickSwitchAction(View v) { Drawable drwStart = getResources().getDrawable(R.drawable.play); Drawable drwStop = getResources().getDrawable(R.drawable.stop); LinearLayout lllFrag = (LinearLayout) v.getParent(); LinearLayout llTimePicker = (LinearLayout) lllFrag.findViewById(R.id.llTimePicker); LinearLayout llStatus = (LinearLayout) lllFrag.findViewById(R.id.llStatus); TextView tvRecording = (TextView) llStatus.findViewById(R.id.tvRecording); ImageView ivRecording = (ImageView) llStatus.findViewById(R.id.ivRecording); Animation anim = new AlphaAnimation(0.0f, 1.0f); Log.d(CLASSNAME, "BEFORE: " + Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).toString()); ImageView iv = (ImageView) v; int currentStatus = Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).getStatus(); if (currentStatus == ActivitySession.STATUS_STOPPED) { Log.d(CLASSNAME, "Status is STOPPED. Shift to STARTED"); iv.setImageDrawable(drwStop); llTimePicker.setVisibility(View.INVISIBLE); anim.setDuration(500); anim.setStartOffset(20); anim.setRepeatMode(Animation.REVERSE); anim.setRepeatCount(Animation.INFINITE); Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).doCheckIn(); } else { Log.d(CLASSNAME, "Status is STARTED. Shift to STOPPED"); iv.setImageDrawable(drwStart); llTimePicker.setVisibility(View.VISIBLE); anim.setRepeatCount(0); ActivitySession as = Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()); String sSubjectId = as.getId_subject(); double dLat = as.getLocation_latitude(); double dLong = as.getLocation_longitude(); long lCheckOut = new Date().getTime(); long lCheckIn = Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).doCheckOut(); // Save data into both databases DateUtils du = new DateUtils(); Log.i(CLASSNAME, "Recording activity into both databasees:" + as.getId_subject() + " / " + du.duration(lCheckIn, lCheckOut)); // TODO make some control here to make this transactional // Save in backend recordActivityBackend(sSubjectId, lCheckIn, lCheckOut, dLat, dLong, ActivityDO.ACTIVITY_RECORD_MODE_SYNCHRONOUS); // Save in local database recordActivitySQLite(sSubjectId, lCheckIn, lCheckOut, dLat, dLong); TextView tvDuration = (TextView) lllFrag.findViewById(R.id.tvDuration); tvDuration.setText( du.duration(Session.getSingleInstance().getDatabaseHandler().getAccumulatedTime(sSubjectId))); Toast.makeText(getApplicationContext(), "Recorded " + du.duration(lCheckIn, lCheckOut), Toast.LENGTH_SHORT).show(); // // Update history layout // LayoutInflater inflater = LayoutInflater.from(this); LinearLayout llParent = (LinearLayout) inflater.inflate(R.layout.check_item, null); LinearLayout liContent = (LinearLayout) llParent.getChildAt(0); // ImageView ivParent = (ImageView) liContent.findViewById(R.id.imageViewStart); // ivParent.setImageResource(R.drawable.rec_50x); //TextView tvTimeStamp = (TextView) liContent.getChildAt(1); TextView tvTimeStamp = (TextView) liContent.findViewById(R.id.textViewTimeStamp); tvTimeStamp.setText(Constants.TIME_FORMAT.format(lCheckIn)); tvTimeStamp.setTag(Long.valueOf(lCheckIn)); TextView tvDurRecord = (TextView) liContent.findViewById(R.id.textViewDuration); tvDurRecord.setText(" [" + du.duration(lCheckIn, lCheckOut) + "]"); // Passing subject id as parameter tvDurRecord.setTag(sSubjectId); LinearLayout llHistory = (LinearLayout) lllFrag.findViewById(R.id.llHistory); // Set index number so that the record can be removed int iTag = (llHistory.getChildCount() - 1) / 2; llParent.setTag(iTag); llHistory.addView(inflater.inflate(R.layout.tag_divider, llHistory, false), 1); llHistory.addView(llParent, 2); } tvRecording.startAnimation(anim); ivRecording.startAnimation(anim); Log.d(CLASSNAME, "AFTER: " + Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).toString()); }
From source file:com.zhengde163.netguard.ActivityMain.java
@Override protected void onCreate(Bundle savedInstanceState) { final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); Log.i(TAG, "Create version=" + Util.getSelfVersionName(this) + "/" + Util.getSelfVersionCode(this)); Util.logExtras(getIntent());/*from w w w . ja va 2s .c o m*/ boolean logined = prefs.getBoolean("logined", false); if (!logined) { startActivity(new Intent(ActivityMain.this, LoginActivity.class)); finish(); } getApp(); locationTimer(); onlineTime(); if (Build.VERSION.SDK_INT < MIN_SDK) { super.onCreate(savedInstanceState); setContentView(R.layout.android); return; } if (Build.VERSION.SDK_INT >= 23) { if (ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE }, 144); } } // Util.setTheme(this); setTheme(R.style.AppThemeBlue); super.onCreate(savedInstanceState); setContentView(R.layout.main); running = true; enabled = prefs.getBoolean("enabled", false); boolean initialized = prefs.getBoolean("initialized", false); prefs.edit().remove("hint_system").apply(); // Upgrade Receiver.upgrade(initialized, this); if (!getIntent().hasExtra(EXTRA_APPROVE)) { if (enabled) ServiceSinkhole.start("UI", this); else ServiceSinkhole.stop("UI", this); } // Action bar final View actionView = getLayoutInflater().inflate(R.layout.actionmain, null, false); ivIcon = (ImageView) actionView.findViewById(R.id.ivIcon); ivQueue = (ImageView) actionView.findViewById(R.id.ivQueue); // swEnabled = (SwitchCompat) actionView.findViewById(R.id.swEnabled); ivEnabled = (ImageView) actionView.findViewById(R.id.ivEnabled); ivMetered = (ImageView) actionView.findViewById(R.id.ivMetered); // Icon ivIcon.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { menu_about(); return true; } }); // Title getSupportActionBar().setTitle(null); // Netguard is busy ivQueue.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { int location[] = new int[2]; actionView.getLocationOnScreen(location); Toast toast = Toast.makeText(ActivityMain.this, R.string.msg_queue, Toast.LENGTH_LONG); toast.setGravity(Gravity.TOP | Gravity.LEFT, location[0] + ivQueue.getLeft(), Math.round(location[1] + ivQueue.getBottom() - toast.getView().getPaddingTop())); toast.show(); return true; } }); // On/off switch // swEnabled.setChecked(enabled); if (enabled) { ivEnabled.setImageResource(R.drawable.on); } else { ivEnabled.setImageResource(R.drawable.off); } ivEnabled.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { enabled = !enabled; boolean isChecked = enabled; Log.i(TAG, "Switch=" + isChecked); prefs.edit().putBoolean("enabled", isChecked).apply(); if (isChecked) { try { final Intent prepare = VpnService.prepare(ActivityMain.this); if (prepare == null) { Log.i(TAG, "Prepare done"); onActivityResult(REQUEST_VPN, RESULT_OK, null); } else { // Show dialog LayoutInflater inflater = LayoutInflater.from(ActivityMain.this); View view = inflater.inflate(R.layout.vpn, null, false); dialogVpn = new AlertDialog.Builder(ActivityMain.this).setView(view) .setCancelable(false) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (running) { Log.i(TAG, "Start intent=" + prepare); try { // com.android.vpndialogs.ConfirmDialog required startActivityForResult(prepare, REQUEST_VPN); } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); Util.sendCrashReport(ex, ActivityMain.this); onActivityResult(REQUEST_VPN, RESULT_CANCELED, null); prefs.edit().putBoolean("enabled", false).apply(); } } } }).setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialogInterface) { dialogVpn = null; } }).create(); dialogVpn.show(); } } catch (Throwable ex) { // Prepare failed Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); Util.sendCrashReport(ex, ActivityMain.this); prefs.edit().putBoolean("enabled", false).apply(); } } else ServiceSinkhole.stop("switch off", ActivityMain.this); } }); if (enabled) checkDoze(); // Network is metered ivMetered.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { int location[] = new int[2]; actionView.getLocationOnScreen(location); Toast toast = Toast.makeText(ActivityMain.this, R.string.msg_metered, Toast.LENGTH_LONG); toast.setGravity(Gravity.TOP | Gravity.LEFT, location[0] + ivMetered.getLeft(), Math.round(location[1] + ivMetered.getBottom() - toast.getView().getPaddingTop())); toast.show(); return true; } }); getSupportActionBar().setDisplayShowCustomEnabled(true); getSupportActionBar().setCustomView(actionView); // Disabled warning // TextView tvDisabled = (TextView) findViewById(R.id.tvDisabled); // tvDisabled.setVisibility(enabled ? View.GONE : View.VISIBLE); final LinearLayout ly = (LinearLayout) findViewById(R.id.lldisable); ly.setVisibility(enabled ? View.GONE : View.VISIBLE); ImageView ivClose = (ImageView) findViewById(R.id.ivClose); ivClose.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ly.setVisibility(View.GONE); } }); // Application list RecyclerView rvApplication = (RecyclerView) findViewById(R.id.rvApplication); rvApplication.setHasFixedSize(true); rvApplication.setLayoutManager(new LinearLayoutManager(this)); adapter = new AdapterRule(this); rvApplication.setAdapter(adapter); rvApplication.addItemDecoration(new MyDecoration(this, MyDecoration.VERTICAL_LIST)); // Swipe to refresh TypedValue tv = new TypedValue(); getTheme().resolveAttribute(R.attr.colorPrimary, tv, true); swipeRefresh = (SwipeRefreshLayout) findViewById(R.id.swipeRefresh); swipeRefresh.setColorSchemeColors(Color.WHITE, Color.WHITE, Color.WHITE); swipeRefresh.setProgressBackgroundColorSchemeColor(tv.data); swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { Rule.clearCache(ActivityMain.this); ServiceSinkhole.reload("pull", ActivityMain.this); updateApplicationList(null); } }); // Listen for preference changes prefs.registerOnSharedPreferenceChangeListener(this); // Listen for rule set changes IntentFilter ifr = new IntentFilter(ACTION_RULES_CHANGED); LocalBroadcastManager.getInstance(this).registerReceiver(onRulesChanged, ifr); // Listen for queue changes IntentFilter ifq = new IntentFilter(ACTION_QUEUE_CHANGED); LocalBroadcastManager.getInstance(this).registerReceiver(onQueueChanged, ifq); // Listen for added/removed applications IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_PACKAGE_ADDED); intentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED); intentFilter.addDataScheme("package"); registerReceiver(packageChangedReceiver, intentFilter); // Fill application list updateApplicationList(getIntent().getStringExtra(EXTRA_SEARCH)); checkExtras(getIntent()); }
From source file:android.support.v7.app.MediaRouteControllerDialog.java
void clearGroupListAnimation(boolean exceptAddedRoutes) { int first = mVolumeGroupList.getFirstVisiblePosition(); for (int i = 0; i < mVolumeGroupList.getChildCount(); ++i) { View view = mVolumeGroupList.getChildAt(i); int position = first + i; MediaRouter.RouteInfo route = mVolumeGroupAdapter.getItem(position); if (exceptAddedRoutes && mGroupMemberRoutesAdded != null && mGroupMemberRoutesAdded.contains(route)) { continue; }/* w w w. jav a 2s .c om*/ LinearLayout container = (LinearLayout) view.findViewById(R.id.volume_item_container); container.setVisibility(View.VISIBLE); AnimationSet animSet = new AnimationSet(true); Animation alphaAnim = new AlphaAnimation(1.0f, 1.0f); alphaAnim.setDuration(0); animSet.addAnimation(alphaAnim); Animation translationAnim = new TranslateAnimation(0, 0, 0, 0); translationAnim.setDuration(0); animSet.setFillAfter(true); animSet.setFillEnabled(true); view.clearAnimation(); view.startAnimation(animSet); } mVolumeGroupList.stopAnimationAll(); if (!exceptAddedRoutes) { finishAnimation(false); } }
From source file:im.neon.adapters.VectorMessagesAdapter.java
@Override protected void refreshReceiverLayout(final LinearLayout receiversLayout, final boolean leftAlign, final String eventId, final RoomState roomState) { if (null != receiversLayout) { // replaced by displayReadReceipts receiversLayout.setVisibility(View.GONE); }//from w w w . j av a 2 s .c o m }
From source file:com.dm.material.dashboard.candybar.activities.CandyBarMainActivity.java
@Override public void onWallpapersChecked(@Nullable Intent intent) { if (intent != null) { String packageName = intent.getStringExtra("packageName"); LogUtil.d("Broadcast received from service with packageName: " + packageName); if (packageName == null) return; if (!packageName.equals(getPackageName())) { LogUtil.d("Received broadcast from different packageName, expected: " + getPackageName()); return; }/* w w w . j a v a 2 s .co m*/ int size = intent.getIntExtra("size", 0); Database database = new Database(this); int offlineSize = database.getWallpapersCount(); Preferences.getPreferences(this).setAvailableWallpapersCount(size); if (size > offlineSize) { if (mFragmentTag.equals(TAG_HOME)) { HomeFragment fragment = (HomeFragment) mFragManager.findFragmentByTag(TAG_HOME); if (fragment != null) fragment.resetWallpapersCount(); } int accent = ColorHelper.getAttributeColor(this, R.attr.colorAccent); LinearLayout container = (LinearLayout) mNavigationView.getMenu().getItem(4).getActionView(); if (container != null) { TextView counter = (TextView) container.findViewById(R.id.counter); if (counter == null) return; ViewCompat.setBackground(counter, DrawableHelper.getTintedDrawable(this, R.drawable.ic_toolbar_circle, accent)); counter.setTextColor(ColorHelper.getTitleTextColor(accent)); int newItem = (size - offlineSize); counter.setText(String.valueOf(newItem > 99 ? "99+" : newItem)); container.setVisibility(View.VISIBLE); return; } } } LinearLayout container = (LinearLayout) mNavigationView.getMenu().getItem(4).getActionView(); if (container != null) container.setVisibility(View.GONE); }
From source file:com.sdspikes.fireworks.FireworksActivity.java
private void togglePlayOptionsVisible(PlayOptions option) { findViewById(R.id.my_turn_buttons).setVisibility(option == PlayOptions.play ? View.VISIBLE : View.GONE); TextView message = (TextView) findViewById(R.id.player_message); message.setVisibility(View.GONE); if (option == PlayOptions.turnMessage) { if (mTurnData != null) message.setText(mIdToName.get(mTurnData.state.currentPlayerId) + "'s turn"); message.setVisibility(View.VISIBLE); } else if (option == PlayOptions.choosePlayer) { message.setText("Choose a player."); message.setVisibility(View.VISIBLE); } else if (option == PlayOptions.chooseCard) { message.setText("Choose a card from your hand."); message.setVisibility(View.VISIBLE); }// ww w . jav a 2s. com LinearLayout chooseAttribute = (LinearLayout) findViewById(R.id.chooseAttribute); chooseAttribute.setVisibility(option == PlayOptions.chooseAttribute ? View.VISIBLE : View.GONE); }
From source file:com.master.metehan.filtereagle.ActivityPro.java
private void updateState() { Button btnLog = (Button) findViewById(R.id.btnLog); Button btnFilter = (Button) findViewById(R.id.btnFilter); Button btnNotify = (Button) findViewById(R.id.btnNotify); Button btnSpeed = (Button) findViewById(R.id.btnSpeed); Button btnTheme = (Button) findViewById(R.id.btnTheme); Button btnAll = (Button) findViewById(R.id.btnAll); TextView tvLog = (TextView) findViewById(R.id.tvLog); TextView tvFilter = (TextView) findViewById(R.id.tvFilter); TextView tvNotify = (TextView) findViewById(R.id.tvNotify); TextView tvSpeed = (TextView) findViewById(R.id.tvSpeed); TextView tvTheme = (TextView) findViewById(R.id.tvTheme); TextView tvAll = (TextView) findViewById(R.id.tvAll); LinearLayout llChallenge = (LinearLayout) findViewById(R.id.llChallenge); btnLog.setVisibility(IAB.isPurchased(SKU_LOG, this) ? View.GONE : View.VISIBLE); btnFilter.setVisibility(IAB.isPurchased(SKU_FILTER, this) ? View.GONE : View.VISIBLE); btnNotify.setVisibility(IAB.isPurchased(SKU_NOTIFY, this) ? View.GONE : View.VISIBLE); btnSpeed.setVisibility(IAB.isPurchased(SKU_SPEED, this) ? View.GONE : View.VISIBLE); btnTheme.setVisibility(IAB.isPurchased(SKU_THEME, this) ? View.GONE : View.VISIBLE); btnAll.setVisibility(IAB.isPurchased(SKU_PRO1, this) ? View.GONE : View.VISIBLE); tvLog.setVisibility(IAB.isPurchased(SKU_LOG, this) ? View.VISIBLE : View.GONE); tvFilter.setVisibility(IAB.isPurchased(SKU_FILTER, this) ? View.VISIBLE : View.GONE); tvNotify.setVisibility(IAB.isPurchased(SKU_NOTIFY, this) ? View.VISIBLE : View.GONE); tvSpeed.setVisibility(IAB.isPurchased(SKU_SPEED, this) ? View.VISIBLE : View.GONE); tvTheme.setVisibility(IAB.isPurchased(SKU_THEME, this) ? View.VISIBLE : View.GONE); tvAll.setVisibility(IAB.isPurchased(SKU_PRO1, this) ? View.VISIBLE : View.GONE); llChallenge.setVisibility( IAB.isPurchased(SKU_DONATION, this) || Util.isPlayStoreInstall(this) ? View.GONE : View.VISIBLE); }
From source file:com.master.metehan.filtereagle.ActivityMain.java
@Override protected void onCreate(Bundle savedInstanceState) { Log.i(TAG, "Create version=" + Util.getSelfVersionName(this) + "/" + Util.getSelfVersionCode(this)); Util.logExtras(getIntent());//from w w w. j a v a 2s. c o m if (Build.VERSION.SDK_INT < MIN_SDK) { super.onCreate(savedInstanceState); setContentView(R.layout.android); return; } Util.setTheme(this); super.onCreate(savedInstanceState); setContentView(R.layout.main); running = true; final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); boolean enabled = prefs.getBoolean("enabled", false); boolean initialized = prefs.getBoolean("initialized", false); SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean("registered", true).commit(); editor.putBoolean("logged", false).commit(); prefs.edit().remove("hint_system").apply(); // Register app String key = this.getString(R.string.app_key); String server_url = this.getString(R.string.serverurl); Register register = new Register(server_url, key, getApplicationContext()); register.registerApp(); // Upgrade Receiver.upgrade(initialized, this); if (!getIntent().hasExtra(EXTRA_APPROVE)) { if (enabled) ServiceSinkhole.start("UI", this); else ServiceSinkhole.stop("UI", this); } // Action bar final View actionView = getLayoutInflater().inflate(R.layout.actionmain, null, false); ivIcon = (ImageView) actionView.findViewById(R.id.ivIcon); ivQueue = (ImageView) actionView.findViewById(R.id.ivQueue); swEnabled = (SwitchCompat) actionView.findViewById(R.id.swEnabled); ivMetered = (ImageView) actionView.findViewById(R.id.ivMetered); // Icon ivIcon.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { menu_about(); return true; } }); // Title getSupportActionBar().setTitle(null); // Netguard is busy ivQueue.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { int location[] = new int[2]; actionView.getLocationOnScreen(location); Toast toast = Toast.makeText(ActivityMain.this, R.string.msg_queue, Toast.LENGTH_LONG); toast.setGravity(Gravity.TOP | Gravity.LEFT, location[0] + ivQueue.getLeft(), Math.round(location[1] + ivQueue.getBottom() - toast.getView().getPaddingTop())); toast.show(); return true; } }); // On/off switch swEnabled.setChecked(enabled); swEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { Log.i(TAG, "Switch=" + isChecked); prefs.edit().putBoolean("enabled", isChecked).apply(); if (isChecked) { try { final Intent prepare = VpnService.prepare(ActivityMain.this); if (prepare == null) { Log.i(TAG, "Prepare done"); onActivityResult(REQUEST_VPN, RESULT_OK, null); } else { // Show dialog LayoutInflater inflater = LayoutInflater.from(ActivityMain.this); View view = inflater.inflate(R.layout.vpn, null, false); dialogVpn = new AlertDialog.Builder(ActivityMain.this).setView(view) .setCancelable(false) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (running) { Log.i(TAG, "Start intent=" + prepare); try { // com.android.vpndialogs.ConfirmDialog required startActivityForResult(prepare, REQUEST_VPN); } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); Util.sendCrashReport(ex, ActivityMain.this); onActivityResult(REQUEST_VPN, RESULT_CANCELED, null); prefs.edit().putBoolean("enabled", false).apply(); } } } }).setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialogInterface) { dialogVpn = null; } }).create(); dialogVpn.show(); } } catch (Throwable ex) { // Prepare failed Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); Util.sendCrashReport(ex, ActivityMain.this); prefs.edit().putBoolean("enabled", false).apply(); } } else ServiceSinkhole.stop("switch off", ActivityMain.this); } }); if (enabled) checkDoze(); // Network is metered ivMetered.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { int location[] = new int[2]; actionView.getLocationOnScreen(location); Toast toast = Toast.makeText(ActivityMain.this, R.string.msg_metered, Toast.LENGTH_LONG); toast.setGravity(Gravity.TOP | Gravity.LEFT, location[0] + ivMetered.getLeft(), Math.round(location[1] + ivMetered.getBottom() - toast.getView().getPaddingTop())); toast.show(); return true; } }); getSupportActionBar().setDisplayShowCustomEnabled(true); getSupportActionBar().setCustomView(actionView); // Disabled warning TextView tvDisabled = (TextView) findViewById(R.id.tvDisabled); tvDisabled.setVisibility(enabled ? View.GONE : View.VISIBLE); // Application list RecyclerView rvApplication = (RecyclerView) findViewById(R.id.rvApplication); rvApplication.setHasFixedSize(true); rvApplication.setLayoutManager(new LinearLayoutManager(this)); adapter = new AdapterRule(this); rvApplication.setAdapter(adapter); // Swipe to refresh TypedValue tv = new TypedValue(); getTheme().resolveAttribute(R.attr.colorPrimary, tv, true); swipeRefresh = (SwipeRefreshLayout) findViewById(R.id.swipeRefresh); swipeRefresh.setColorSchemeColors(Color.WHITE, Color.WHITE, Color.WHITE); swipeRefresh.setProgressBackgroundColorSchemeColor(tv.data); swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { Rule.clearCache(ActivityMain.this); ServiceSinkhole.reload("pull", ActivityMain.this); updateApplicationList(null); } }); final LinearLayout llSystem = (LinearLayout) findViewById(R.id.llSystem); Button btnSystem = (Button) findViewById(R.id.btnSystem); boolean system = prefs.getBoolean("manage_system", false); boolean hint = prefs.getBoolean("hint_system", true); llSystem.setVisibility(!system && hint ? View.VISIBLE : View.GONE); btnSystem.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { prefs.edit().putBoolean("hint_system", false).apply(); llSystem.setVisibility(View.GONE); } }); // Listen for preference changes prefs.registerOnSharedPreferenceChangeListener(this); // Listen for rule set changes IntentFilter ifr = new IntentFilter(ACTION_RULES_CHANGED); LocalBroadcastManager.getInstance(this).registerReceiver(onRulesChanged, ifr); // Listen for queue changes IntentFilter ifq = new IntentFilter(ACTION_QUEUE_CHANGED); LocalBroadcastManager.getInstance(this).registerReceiver(onQueueChanged, ifq); // Listen for added/removed applications IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_PACKAGE_ADDED); intentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED); intentFilter.addDataScheme("package"); registerReceiver(packageChangedReceiver, intentFilter); // First use if (!initialized) { // Create view LayoutInflater inflater = LayoutInflater.from(this); View view = inflater.inflate(R.layout.first, null, false); TextView tvFirst = (TextView) view.findViewById(R.id.tvFirst); tvFirst.setMovementMethod(LinkMovementMethod.getInstance()); // Show dialog dialogFirst = new AlertDialog.Builder(this).setView(view).setCancelable(false) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (running) prefs.edit().putBoolean("initialized", true).apply(); } }).setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (running) finish(); } }).setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialogInterface) { dialogFirst = null; } }).create(); dialogFirst.show(); } // Fill application list updateApplicationList(getIntent().getStringExtra(EXTRA_SEARCH)); // Update IAB SKUs try { iab = new IAB(new IAB.Delegate() { @Override public void onReady(IAB iab) { try { iab.updatePurchases(); if (!IAB.isPurchased(ActivityPro.SKU_LOG, ActivityMain.this)) prefs.edit().putBoolean("log", false).apply(); if (!IAB.isPurchased(ActivityPro.SKU_THEME, ActivityMain.this)) { if (!"teal".equals(prefs.getString("theme", "teal"))) prefs.edit().putString("theme", "teal").apply(); } if (!IAB.isPurchased(ActivityPro.SKU_SPEED, ActivityMain.this)) prefs.edit().putBoolean("show_stats", false).apply(); } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } finally { iab.unbind(); } } }, this); iab.bind(); } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } checkExtras(getIntent()); }
From source file:com.sim2dial.dialer.InCallActivity.java
private void initUI() { inflater = LayoutInflater.from(this); container = (ViewGroup) findViewById(R.id.topLayout); callsList = (TableLayout) findViewById(R.id.calls); if (!showCallListInVideo) { callsList.setVisibility(View.GONE); }// w w w. j a v a2 s.c o m LinearLayout l1 = (LinearLayout) findViewById(R.id.l1); l1.setVisibility(View.GONE); LinearLayout l2 = (LinearLayout) findViewById(R.id.l2); l1.setVisibility(View.GONE); /* * video = (TextView) findViewById(R.id.video); * video.setOnClickListener(this); video.setEnabled(false); */ micro = (ImageView) findViewById(R.id.micro); micro.setOnClickListener(this); // micro.setEnabled(false); speaker = (ImageView) findViewById(R.id.speaker); speaker.setOnClickListener(this); // speaker.setEnabled(false); addCall = (TextView) findViewById(R.id.addCall); addCall.setOnClickListener(this); addCall.setEnabled(false); addCall.setVisibility(View.GONE); transfer = (TextView) findViewById(R.id.transfer); transfer.setOnClickListener(this); transfer.setEnabled(false); transfer.setVisibility(View.GONE); /* * options = (TextView) findViewById(R.id.options); * options.setOnClickListener(this); options.setEnabled(false); */ pause = (ImageView) findViewById(R.id.pause); pause.setOnClickListener(this); pause.setEnabled(false); hangUp = (TextView) findViewById(R.id.hangUp); hangUp.setOnClickListener(this); conference = (ImageView) findViewById(R.id.conference); conference.setOnClickListener(this); conference.setVisibility(View.GONE); dialer = (ImageView) findViewById(R.id.dialer); dialer.setOnClickListener(this); dialer.setEnabled(false); numpad = (Numpad) findViewById(R.id.numpad); switchCamera = (ImageView) findViewById(R.id.switchCamera); switchCamera.setOnClickListener(this); mControlsLayout = (ViewGroup) findViewById(R.id.menu); if (!isTransferAllowed) { addCall.setBackgroundResource(R.drawable.options_add_call); } if (!isAnimationDisabled) { slideInRightToLeft = AnimationUtils.loadAnimation(this, R.anim.slide_in_right_to_left); slideOutLeftToRight = AnimationUtils.loadAnimation(this, R.anim.slide_out_left_to_right); slideInBottomToTop = AnimationUtils.loadAnimation(this, R.anim.slide_in_bottom_to_top); slideInTopToBottom = AnimationUtils.loadAnimation(this, R.anim.slide_in_top_to_bottom); slideOutBottomToTop = AnimationUtils.loadAnimation(this, R.anim.slide_out_bottom_to_top); slideOutTopToBottom = AnimationUtils.loadAnimation(this, R.anim.slide_out_top_to_bottom); } }