Search in sources :

Example 31 with ImageButton

use of android.widget.ImageButton in project GT by Tencent.

the class GTOpSMActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gt_perf_op_detail_sm);
    Intent intent = this.getIntent();
    Bundle extras = intent.getExtras();
    final String name = extras.getString("name");
    final String alias = extras.getString("alias");
    final String client = extras.getString("client");
    // 出参的性能数据源取法
    dataSet = OpPerfBridge.getProfilerData(name);
    // 在onCreat之前数据源可能被清理了,这样就不打开页面
    if (null == dataSet) {
        finish();
        return;
    }
    // 保存对应的出参变量,以便刷值
    op = ClientManager.getInstance().getClient(client).getOutPara(name);
    about = dataSet.getDesc();
    tvTitle = (TextView) findViewById(R.id.perf_detail_title);
    //		tvTitle.setText(alias);
    tvTitle.setText("SM for Test");
    tvKey = (TextView) findViewById(R.id.op_perf_detail_key);
    tvKey.setText(name);
    tvAbout = (TextView) findViewById(R.id.op_perf_detail_about);
    tvAbout.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            GTOutParaPerfDialog dialog = new GTOutParaPerfDialog(v.getContext(), alias, name, about);
            dialog.show();
        }
    });
    btn_back = (ImageButton) findViewById(R.id.perf_detail_back);
    btn_back.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            finish();
        }
    });
    //		btn_save = (ImageButton)findViewById(R.id.perf_detail_save);
    //		btn_save.setOnClickListener(new OnClickListener() {
    //
    //			public void onClick(View v) {
    //				String lastSaveLog = GTGWInternal.getLastSaveFolder();
    //				if (lastSaveLog != null && lastSaveLog.contains(".")
    //						&& lastSaveLog.endsWith(LogUtils.TLOG_POSFIX))
    //				{
    //					lastSaveLog = lastSaveLog.substring(0, lastSaveLog.lastIndexOf("."));
    //				}
    //				et_savePath3.setText(lastSaveLog.trim());
    //				dlg_save.show();
    //			}
    //		});
    btn_delete = (ImageButton) findViewById(R.id.perf_detail_delete);
    btn_delete.setOnClickListener(showDeleteDlg);
    // 告警区
    final LinearLayout ll_warnArea = (LinearLayout) findViewById(R.id.op_perf_detail_warnarea);
    img_bottom_arrow = (ImageView) findViewById(R.id.bottom_arrow);
    if (dataSet.getThresholdEntry().isEnable()) {
        img_bottom_arrow.setBackgroundResource(R.drawable.unfold_arrow);
        ll_warnArea.setVisibility(View.VISIBLE);
    } else {
        img_bottom_arrow.setBackgroundResource(R.drawable.fold_arrow);
        ll_warnArea.setVisibility(View.GONE);
    }
    // 告警抬头文本
    tvWaringArea = (TextView) findViewById(R.id.op_perf_detail_interval_toast);
    if (!dataSet.getThresholdEntry().isEnable()) {
        tvWaringArea.setText(getString(R.string.warning_title_disable));
    }
    // 折叠线
    ll_fold = (LinearLayout) findViewById(R.id.warning_fold);
    ll_fold.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (dataSet.getThresholdEntry().isEnable()) {
                dataSet.getThresholdEntry().setEnable(false);
                img_bottom_arrow.setBackgroundResource(R.drawable.fold_arrow);
                ll_warnArea.setVisibility(View.GONE);
                tvWaringArea.setText(getString(R.string.warning_title_disable));
            } else {
                dataSet.getThresholdEntry().setEnable(true);
                img_bottom_arrow.setBackgroundResource(R.drawable.unfold_arrow);
                ll_warnArea.setVisibility(View.VISIBLE);
                tvWaringArea.setText(getString(R.string.warning_title));
            }
        }
    });
    etUpperInterval = (EditText) findViewById(R.id.op_perf_detail_upper_interval);
    etUpperValue = (EditText) findViewById(R.id.op_perf_detail_upper_value);
    etLowerValue = (EditText) findViewById(R.id.op_perf_detail_lower_value);
    // 从未开始统计过的出参,不允许设置告警
    if (!op.hasMonitorOnce) {
        etUpperInterval.setEnabled(false);
        etUpperValue.setEnabled(false);
        etLowerValue.setEnabled(false);
    //			isfoldWarnArea = true;
    //			img_bottom_arrow.setBackgroundResource(R.drawable.unfold_arrow);
    //			ll_warnArea.setVisibility(View.GONE);
    } else {
        etUpperInterval.setInputType(EditorInfo.TYPE_CLASS_PHONE);
        etUpperValue.setInputType(EditorInfo.TYPE_CLASS_PHONE);
        etLowerValue.setInputType(EditorInfo.TYPE_CLASS_PHONE);
        etUpperInterval.setOnKeyListener(thresholdKeyListener);
        etUpperValue.setOnKeyListener(thresholdKeyListener);
        etLowerValue.setOnKeyListener(thresholdKeyListener);
        int upperDuration = dataSet.getThresholdEntry().getduration();
        if (upperDuration != Integer.MAX_VALUE) {
            etUpperInterval.setText(Integer.toString(upperDuration));
        }
        double upperValue = dataSet.getThresholdEntry().getUpperValue();
        if (upperValue != Integer.MAX_VALUE) {
            etUpperValue.setText(Double.toString(upperValue));
        }
        double lowerValue = dataSet.getThresholdEntry().getLowerValue();
        if (lowerValue != Integer.MIN_VALUE) {
            etLowerValue.setText(Double.toString(lowerValue));
        }
    }
    RelativeLayout rl_save = (RelativeLayout) LayoutInflater.from(this).inflate(R.layout.gt_dailog_save_gw, null, false);
    ImageButton btn_cleanSavePath = (ImageButton) rl_save.findViewById(R.id.save_clean);
    btn_cleanSavePath.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            et_savePath3.setText("");
        }
    });
    et_savePath1 = (EditText) rl_save.findViewById(R.id.save_editor_folder_parent1);
    et_savePath2 = (EditText) rl_save.findViewById(R.id.save_editor_folder_parent2);
    et_savePath3 = (EditText) rl_save.findViewById(R.id.save_editor);
    et_saveTestDesc = (EditText) rl_save.findViewById(R.id.save_editor_desc);
    String lastSaveLog = GTGWInternal.getLastSaveFolder();
    if (lastSaveLog != null && lastSaveLog.contains(".") && lastSaveLog.endsWith(LogUtils.TLOG_POSFIX)) {
        lastSaveLog = lastSaveLog.substring(0, lastSaveLog.lastIndexOf("."));
    }
    et_savePath3.setText(lastSaveLog);
    et_savePath1.setText(Env.CUR_APP_NAME);
    et_savePath2.setText(Env.CUR_APP_VER);
    dlg_save = new Builder(this).setTitle(getString(R.string.save)).setView(rl_save).setPositiveButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    }).setNegativeButton(getString(R.string.ok), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            String path1 = et_savePath1.getText().toString().trim();
            if (!StringUtil.isLetter(path1)) {
                ToastUtil.ShowShortToast(GTOpSMActivity.this, getString(R.string.save_folder_valid));
                return;
            }
            String path2 = et_savePath2.getText().toString().trim();
            if (!StringUtil.isLetter(path2)) {
                ToastUtil.ShowShortToast(GTOpSMActivity.this, getString(R.string.save_folder_valid));
                return;
            }
            String path3 = et_savePath3.getText().toString().trim();
            if (!StringUtil.isLetter(path3)) {
                ToastUtil.ShowShortToast(GTOpSMActivity.this, getString(R.string.save_folder_valid));
                return;
            }
            String testDesc = et_saveTestDesc.getText().toString().trim();
            GWSaveEntry saveEntry = new GWSaveEntry(path1, path2, path3, testDesc);
            GTGWInternal.saveGWDataForSM(saveEntry, dataSet);
            dialog.dismiss();
        }
    }).create();
    tvValue = (TextView) findViewById(R.id.op_perf_detail_value);
    tvTimes = (TextView) findViewById(R.id.bh_perf_detail_times);
    tvMin = (TextView) findViewById(R.id.bh_perf_detail_min);
    //		tvMax = (TextView) findViewById(R.id.bh_perf_detail_max);
    tvAve = (TextView) findViewById(R.id.bh_perf_detail_ave);
    tvScore = (TextView) findViewById(R.id.bh_perf_detail_score);
    tvGood = (TextView) findViewById(R.id.bh_perf_detail_good);
    tvBad = (TextView) findViewById(R.id.bh_perf_detail_bad);
    tvWarningCnt = (TextView) findViewById(R.id.bh_perf_detail_warning_cnt);
    if (op == null) {
        tvValue.setText(dataSet.getLastValue());
    } else {
        tvValue.setText(op.getValue());
    }
    TagTimeEntry anchorEntry = dataSet;
    if (dataSet.getSubTagEntrys().length > 0) {
        anchorEntry = dataSet.getSubTagEntrys()[0];
    }
    ArrayList<Integer> smrs = SMUtils.getSmDetail(anchorEntry.getRecordList());
    if (smrs.size() < 6) {
        finish();
        return;
    }
    dataSet.exInt_1 = smrs.get(1);
    dataSet.exInt_2 = smrs.get(3);
    dataSet.exInt_3 = smrs.get(5);
    tvTimes.setText(anchorEntry.getRecordSizeText());
    tvMin.setText(anchorEntry.getMin());
    //		tvMax.setText(anchorEntry.getMax());
    tvAve.setText(anchorEntry.getAve());
    tvScore.setText(smrs.get(5).toString());
    tvGood.setText(smrs.get(3).toString());
    tvBad.setText(smrs.get(1).toString());
    tvWarningCnt.setText(Integer.toString(anchorEntry.getThresholdEntry().getUpperWariningCount() + anchorEntry.getThresholdEntry().getLowerWariningCount()));
    LinearLayout ll_chart = (LinearLayout) findViewById(R.id.bh_perf_detail_chart);
    chartView = new GTPerfDetailView(this, dataSet);
    chartView.setInput(0);
    ll_chart.addView(chartView);
}
Also used : TagTimeEntry(com.tencent.wstt.gt.ui.model.TagTimeEntry) DialogInterface(android.content.DialogInterface) Bundle(android.os.Bundle) Builder(android.app.AlertDialog.Builder) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) GTPerfDetailView(com.tencent.wstt.gt.views.GTPerfDetailView) TextView(android.widget.TextView) GTPerfDetailView(com.tencent.wstt.gt.views.GTPerfDetailView) ImageButton(android.widget.ImageButton) RelativeLayout(android.widget.RelativeLayout) GWSaveEntry(com.tencent.wstt.gt.log.GWSaveEntry) OnClickListener(android.view.View.OnClickListener) GTOutParaPerfDialog(com.tencent.wstt.gt.views.GTOutParaPerfDialog) LinearLayout(android.widget.LinearLayout)

Example 32 with ImageButton

use of android.widget.ImageButton in project GT by Tencent.

the class GTParamOutFragment method onCreateView.

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View layout = inflater.inflate(R.layout.gt_param_out, container, false);
    btn_gw_on = (Button) layout.findViewById(R.id.btn_monitor);
    btn_gw_off = (Button) layout.findViewById(R.id.btn_monitor_stop);
    save = (ImageButton) layout.findViewById(R.id.gwdata_save);
    cleardata = (ImageButton) layout.findViewById(R.id.gwdata_delete);
    btn_gw_on.setOnClickListener(this);
    btn_gw_off.setOnClickListener(this);
    save.setOnClickListener(this);
    cleardata.setOnClickListener(this);
    // 保存对话框
    View rl_save = inflater.inflate(R.layout.gt_dailog_save_gw, null, false);
    ImageButton btn_cleanSavePath = (ImageButton) rl_save.findViewById(R.id.save_clean);
    btn_cleanSavePath.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            et_savePath3.setText("");
        }
    });
    et_savePath1 = (EditText) rl_save.findViewById(R.id.save_editor_folder_parent1);
    et_savePath2 = (EditText) rl_save.findViewById(R.id.save_editor_folder_parent2);
    et_savePath3 = (EditText) rl_save.findViewById(R.id.save_editor);
    et_saveTestDesc = (EditText) rl_save.findViewById(R.id.save_editor_desc);
    invalid_alarm = (TextView) rl_save.findViewById(R.id.invalid_alarm);
    gwhis_save = new Builder(getActivity()).setTitle(getString(R.string.save)).setView(rl_save).setPositiveButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            canCloseDialog(dialog, true);
        }
    }).setNegativeButton(getString(R.string.ok), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            listProjectPair.clear();
            listProjectName.clear();
            // 先判断保存路径参数是否完整
            final String path3 = et_savePath3.getText().toString().trim();
            final String path2 = et_savePath2.getText().toString().trim();
            final String path1 = et_savePath1.getText().toString().trim();
            if (path1.isEmpty() || path2.isEmpty() || path3.isEmpty()) {
                dismissProDialog();
                canCloseDialog(dialog, false);
                showAlam(R.string.cannot_empty);
                return;
            }
            save2Local();
            canCloseDialog(dialog, true);
        }
    }).create();
    return layout;
}
Also used : ImageButton(android.widget.ImageButton) DialogInterface(android.content.DialogInterface) Builder(android.app.AlertDialog.Builder) OnClickListener(android.view.View.OnClickListener) View(android.view.View) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) ListView(android.widget.ListView)

Example 33 with ImageButton

use of android.widget.ImageButton in project Reader by TheKeeperOfPie.

the class FragmentNewPost method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.fragment_new_post, container, false);
    layoutCoordinator = (CoordinatorLayout) view.findViewById(R.id.layout_coordinator);
    layoutAppBar = (AppBarLayout) view.findViewById(R.id.layout_app_bar);
    scrollText = (NestedScrollView) view.findViewById(R.id.scroll_text);
    textInfo = (TextView) view.findViewById(R.id.text_info);
    textSubmit = (TextView) view.findViewById(R.id.text_submit);
    editTextTitle = (EditText) view.findViewById(R.id.edit_title);
    editTextBody = (EditText) view.findViewById(R.id.edit_body);
    toolbar = (Toolbar) view.findViewById(R.id.toolbar);
    toolbar.setTitle(getString(R.string.new_post));
    toolbar.setTitleTextColor(themer.getColorFilterPrimary().getColor());
    toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
    toolbar.setNavigationOnClickListener(v -> {
        UtilsInput.hideKeyboard(editTextBody);
        mListener.onNavigationBackClick();
    });
    toolbar.getNavigationIcon().mutate().setColorFilter(themer.getColorFilterPrimary());
    setUpOptionsMenu();
    textInfo.setText(getString(R.string.submitting_post, getArguments().getString(SUBREDDIT), getArguments().getString(USER)));
    String submitTextHtml = getArguments().getString(SUBMIT_TEXT_HTML);
    Log.d(TAG, "submitTextHtml: " + submitTextHtml);
    if (TextUtils.isEmpty(submitTextHtml) || "null".equals(submitTextHtml)) {
        textSubmit.setVisibility(View.GONE);
    } else {
        textSubmit.setText(UtilsReddit.getFormattedHtml(submitTextHtml));
    }
    textSubmit.setMovementMethod(LinkMovementMethod.getInstance());
    if (Reddit.PostType.LINK == postType) {
        editTextBody.setHint("URL");
    } else {
        editTextBody.setHint("Text");
    }
    View.OnFocusChangeListener onFocusChangeListener = (v, hasFocus) -> {
        if (hasFocus) {
            AppBarLayout.Behavior behaviorAppBar = (AppBarLayout.Behavior) ((CoordinatorLayout.LayoutParams) layoutAppBar.getLayoutParams()).getBehavior();
            behaviorAppBar.onNestedFling(layoutCoordinator, layoutAppBar, null, 0, 1000, true);
        }
    };
    editTextTitle.setOnFocusChangeListener(onFocusChangeListener);
    editTextBody.setOnFocusChangeListener(onFocusChangeListener);
    editMarginDefault = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics());
    editMarginWithActions = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 56, getResources().getDisplayMetrics());
    textPreview = (TextView) view.findViewById(R.id.text_preview);
    viewDivider = view.findViewById(R.id.view_divider);
    toolbarActions = (Toolbar) view.findViewById(R.id.toolbar_actions);
    toolbarActions.inflateMenu(R.menu.menu_editor_actions);
    toolbarActions.setOnMenuItemClickListener(this);
    tabLayout = (TabLayout) view.findViewById(R.id.layout_tab);
    tabLayout.setTabMode(TabLayout.MODE_FIXED);
    tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
    tabLayout.setTabTextColors(themer.getColorFilterTextMuted().getColor(), themer.getColorFilterPrimary().getColor());
    viewPager = (ViewPager) view.findViewById(R.id.view_pager);
    viewPager.setAdapter(new PagerAdapter() {

        @Override
        public CharSequence getPageTitle(int position) {
            switch(position) {
                case PAGE_POST:
                    return getString(R.string.page_post);
                case PAGE_PREVIEW:
                    return getString(R.string.page_preview);
            }
            return super.getPageTitle(position);
        }

        @Override
        public Object instantiateItem(ViewGroup container, int position) {
            return viewPager.getChildAt(position);
        }

        @Override
        public void destroyItem(ViewGroup container, int position, Object object) {
        }

        @Override
        public int getCount() {
            if (Reddit.PostType.LINK == postType) {
                tabLayout.setVisibility(View.GONE);
                toolbarActions.setVisibility(View.GONE);
                viewDivider.setVisibility(View.GONE);
                itemHideActions.setVisible(false);
                return 1;
            }
            return viewPager.getChildCount();
        }

        @Override
        public boolean isViewFromObject(View view, Object object) {
            return view == object;
        }
    });
    viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            if (position == PAGE_POST && toolbarActions.getVisibility() == View.VISIBLE) {
                float translationY = positionOffset * (toolbarActions.getHeight() + viewDivider.getHeight());
                viewDivider.setTranslationY(translationY);
                toolbarActions.setTranslationY(translationY);
            }
        }

        @Override
        public void onPageSelected(int position) {
            if (position == PAGE_PREVIEW) {
                if (editTextBody.length() == 0) {
                    textPreview.setText(R.string.empty_reply_preview);
                } else {
                    textPreview.setText(Html.fromHtml(Processor.process(editTextBody.getText().toString())));
                }
            }
            if (Reddit.PostType.SELF == postType) {
                itemHideActions.setVisible(position == PAGE_POST);
            }
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });
    tabLayout.setupWithViewPager(viewPager);
    viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
    layoutCaptcha = (RelativeLayout) view.findViewById(R.id.layout_captcha);
    imageCaptcha = (ImageView) view.findViewById(R.id.image_captcha);
    editCaptcha = (EditText) view.findViewById(R.id.edit_captcha);
    buttonCaptchaRefresh = (ImageButton) view.findViewById(R.id.button_captcha_refresh);
    buttonCaptchaRefresh.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            loadCaptcha();
        }
    });
    if (getArguments().getBoolean(IS_EDIT, false)) {
        loadEditValues();
    } else {
        reddit.needsCaptcha().subscribe(new Observer<String>() {

            @Override
            public void onCompleted() {
            }

            @Override
            public void onError(Throwable e) {
                e.printStackTrace();
            }

            @Override
            public void onNext(String response) {
                if ("true".equalsIgnoreCase(response)) {
                    layoutCaptcha.setVisibility(View.VISIBLE);
                    loadCaptcha();
                }
            }
        });
    }
    view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            Menu menu = toolbarActions.getMenu();
            int maxNum = (int) (view.getWidth() / TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 48, getResources().getDisplayMetrics()));
            int numShown = 0;
            for (int index = 0; index < menu.size(); index++) {
                MenuItem menuItem = menu.getItem(index);
                menuItem.getIcon().setColorFilter(themer.getColorFilterIcon());
                if (numShown++ < maxNum - 1) {
                    menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
                } else {
                    menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
                }
            }
            // Toggle visibility to fix weird bug causing tabs to not be added
            tabLayout.setVisibility(View.GONE);
            tabLayout.setVisibility(View.VISIBLE);
            view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
        }
    });
    return view;
}
Also used : AppBarLayout(android.support.design.widget.AppBarLayout) CoordinatorLayout(android.support.design.widget.CoordinatorLayout) ImageButton(android.widget.ImageButton) Bundle(android.os.Bundle) ControllerLinks(com.winsonchiu.reader.links.ControllerLinks) UtilsRx(com.winsonchiu.reader.utils.UtilsRx) ImageView(android.widget.ImageView) ViewPager(android.support.v4.view.ViewPager) LinkMovementMethod(android.text.method.LinkMovementMethod) MenuItem(android.view.MenuItem) TabLayout(android.support.design.widget.TabLayout) Inject(javax.inject.Inject) Picasso(com.squareup.picasso.Picasso) JSONException(org.json.JSONException) Reddit(com.winsonchiu.reader.data.reddit.Reddit) JSONObject(org.json.JSONObject) ComponentStatic(com.winsonchiu.reader.dagger.components.ComponentStatic) Toast(android.widget.Toast) Menu(android.view.Menu) Link(com.winsonchiu.reader.data.reddit.Link) View(android.view.View) JsonNode(com.fasterxml.jackson.databind.JsonNode) NestedScrollView(android.support.v4.widget.NestedScrollView) Log(android.util.Log) Processor(com.github.rjeschke.txtmark.Processor) UtilsInput(com.winsonchiu.reader.utils.UtilsInput) URLUtil(android.webkit.URLUtil) LayoutInflater(android.view.LayoutInflater) Listing(com.winsonchiu.reader.data.reddit.Listing) PagerAdapter(android.support.v4.view.PagerAdapter) TextUtils(android.text.TextUtils) Observer(rx.Observer) UtilsReddit(com.winsonchiu.reader.utils.UtilsReddit) ViewGroup(android.view.ViewGroup) TextView(android.widget.TextView) TypedValue(android.util.TypedValue) Toolbar(android.support.v7.widget.Toolbar) Html(android.text.Html) ViewTreeObserver(android.view.ViewTreeObserver) RelativeLayout(android.widget.RelativeLayout) Nullable(android.support.annotation.Nullable) Activity(android.app.Activity) EditText(android.widget.EditText) PagerAdapter(android.support.v4.view.PagerAdapter) TabLayout(android.support.design.widget.TabLayout) AppBarLayout(android.support.design.widget.AppBarLayout) Menu(android.view.Menu) ViewTreeObserver(android.view.ViewTreeObserver) ViewGroup(android.view.ViewGroup) MenuItem(android.view.MenuItem) ImageView(android.widget.ImageView) View(android.view.View) NestedScrollView(android.support.v4.widget.NestedScrollView) TextView(android.widget.TextView) ViewPager(android.support.v4.view.ViewPager) JSONObject(org.json.JSONObject)

Example 34 with ImageButton

use of android.widget.ImageButton in project storymaker by StoryMaker.

the class BaseActivity method setupDrawerLayout.

public void setupDrawerLayout() {
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerContainer = (ViewGroup) findViewById(R.id.left_drawer);
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer_white, R.string.open_drawer, R.string.close_drawer) {

        /** Called when a drawer has settled in a completely closed state. */
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            // creates call to onPrepareOptionsMenu()
            invalidateOptionsMenu();
            mDrawerOpen = false;
        }

        /** Called when a drawer has settled in a completely open state. */
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            // creates call to onPrepareOptionsMenu()
            invalidateOptionsMenu();
            mDrawerOpen = true;
        }
    };
    mDrawerLayout.setDrawerListener(mDrawerToggle);
    final Activity activity = this;
    RelativeLayout llDrawerLogin = (RelativeLayout) findViewById(R.id.llLogin);
    ImageButton btnDrawerQuickCaptureVideo = (ImageButton) findViewById(R.id.btnDrawerQuickCaptureVideo);
    ImageButton btnDrawerQuickCapturePhoto = (ImageButton) findViewById(R.id.btnDrawerQuickCapturePhoto);
    ImageButton btnDrawerQuickCaptureAudio = (ImageButton) findViewById(R.id.btnDrawerQuickCaptureAudio);
    Button btnDrawerHome = (Button) findViewById(R.id.btnDrawerHome);
    Button btnDrawerCatalog = (Button) findViewById(R.id.btnDrawerCatalog);
    //        Button btnDrawerProjects =      (Button) findViewById(R.id.btnDrawerProjects);
    //Button btnDrawerAccount = (Button) findViewById(R.id.btnDrawerAccount);
    Button btnDrawerAccounts = (Button) findViewById(R.id.btnDrawerAccounts);
    Button btnDrawerExports = (Button) findViewById(R.id.btnDrawerExports);
    Button btnDrawerUploadManager = (Button) findViewById(R.id.btnDrawerUploadManager);
    Button btnDrawerSettings = (Button) findViewById(R.id.btnDrawerSettings);
    Button btnDrawerFeedback = (Button) findViewById(R.id.btnDrawerFeedback);
    TextView textViewVersion = (TextView) findViewById(R.id.textViewVersion);
    // NEW/CACHEWORD
    Button btnDrawerLock = (Button) findViewById(R.id.btnDrawerLock);
    // disable button if the user has set a pin
    SharedPreferences sp = getSharedPreferences("appPrefs", MODE_PRIVATE);
    String cachewordStatus = sp.getString("cacheword_status", "default");
    if (cachewordStatus.equals(CACHEWORD_SET)) {
        Timber.d("pin set, so remove button");
        btnDrawerLock.setVisibility(View.GONE);
    } else {
        Timber.d("no pin set, so show button");
    }
    String pkg = getPackageName();
    try {
        String versionName = getPackageManager().getPackageInfo(pkg, 0).versionName;
        int versionCode = getPackageManager().getPackageInfo(pkg, 0).versionCode;
        textViewVersion.setText("v" + versionName + " build " + versionCode);
    } catch (PackageManager.NameNotFoundException e) {
        Timber.e(e, "NameNotFoundException?");
    }
    updateSlidingMenuWithUserState();
    // Set a random profile background
    ImageView imageViewProfileBg = (ImageView) findViewById(R.id.imageViewProfileBg);
    int profileBg = (int) (Math.random() * 2);
    switch(profileBg) {
        case 0:
            imageViewProfileBg.setImageResource(R.drawable.profile_bg1);
            break;
        case 1:
            imageViewProfileBg.setImageResource(R.drawable.profile_bg2);
            break;
        case 2:
            imageViewProfileBg.setImageResource(R.drawable.profile_bg3);
            break;
    }
    llDrawerLogin.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mDrawerLayout.closeDrawers();
            Intent i = new Intent(activity, ConnectAccountActivity.class);
            activity.startActivity(i);
        }
    });
    btnDrawerHome.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mDrawerLayout.closeDrawers();
            Intent i = new Intent(activity, HomeActivity.class);
            activity.startActivity(i);
        }
    });
    btnDrawerCatalog.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mDrawerLayout.closeDrawers();
            Intent i = new Intent(activity, CatalogActivity.class);
            activity.startActivity(i);
        }
    });
    btnDrawerExports.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mDrawerLayout.closeDrawers();
            Intent i = new Intent(activity, ProjectsActivity.class);
            activity.startActivity(i);
        }
    });
    btnDrawerAccounts.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mDrawerLayout.closeDrawers();
            Intent i = new Intent(activity, AccountsActivity.class);
            activity.startActivity(i);
        }
    });
    btnDrawerUploadManager.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mDrawerLayout.closeDrawers();
            Toast.makeText(getApplicationContext(), "Not yet implemented", Toast.LENGTH_LONG).show();
        //                Intent i = new Intent(activity, AccountsActivity.class);
        //                activity.startActivity(i);
        }
    });
    btnDrawerSettings.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mDrawerLayout.closeDrawers();
            Intent i = new Intent(activity, SimplePreferences.class);
            activity.startActivity(i);
        }
    });
    btnDrawerFeedback.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mDrawerLayout.closeDrawers();
            FeedbackManager.register(activity, AppConstants.HOCKEY_APP_ID, null);
            FeedbackManager.showFeedbackActivity(activity);
        }
    });
    // NEW/CACHEWORD
    btnDrawerLock.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // if there has been no first lock, set status so user will be prompted to create a pin
            SharedPreferences sp = getSharedPreferences("appPrefs", MODE_PRIVATE);
            String cachewordStatus = sp.getString("cacheword_status", "default");
            if (cachewordStatus.equals(CACHEWORD_UNSET)) {
                // set flag so user will be prompted to create a pin
                setPin = true;
                Timber.d("set cacheword first lock flag");
            }
            mCacheWordHandler.lock();
        }
    });
}
Also used : SharedPreferences(android.content.SharedPreferences) ActionBarDrawerToggle(android.support.v4.app.ActionBarDrawerToggle) FragmentActivity(android.support.v4.app.FragmentActivity) Activity(android.app.Activity) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ImageButton(android.widget.ImageButton) PackageManager(android.content.pm.PackageManager) ImageButton(android.widget.ImageButton) Button(android.widget.Button) RelativeLayout(android.widget.RelativeLayout) OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) ImageView(android.widget.ImageView)

Example 35 with ImageButton

use of android.widget.ImageButton in project Anki-Android by Ramblurr.

the class CardEditor method populateEditFields.

private void populateEditFields() {
    mFieldsLayoutContainer.removeAllViews();
    mEditFields = new LinkedList<FieldEditText>();
    String[][] fields = mEditorNote.items();
    // Use custom font if selected from preferences
    Typeface mCustomTypeface = null;
    SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getBaseContext());
    String customFont = preferences.getString("browserEditorFont", "");
    if (!customFont.equals("")) {
        mCustomTypeface = AnkiFont.getTypeface(this, customFont);
    }
    for (int i = 0; i < fields.length; i++) {
        View editline_view = getLayoutInflater().inflate(R.layout.card_multimedia_editline, null);
        FieldEditText newTextbox = (FieldEditText) editline_view.findViewById(R.id.id_note_editText);
        initFieldEditText(newTextbox, i, fields[i], mCustomTypeface);
        TextView label = newTextbox.getLabel();
        label.setTextColor(Color.BLACK);
        label.setPadding((int) UIUtils.getDensityAdjustedValue(this, 3.4f), 0, 0, 0);
        mEditFields.add(newTextbox);
        ImageButton mediaButton = (ImageButton) editline_view.findViewById(R.id.id_media_button);
        mediaButton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent editCard = new Intent(CardEditor.this, MultimediaCardEditorActivity.class);
                if (!mAddNote) {
                    editCard.putExtra(CardEditor.EXTRA_CARD_ID, mCurrentEditedCard.getId());
                } else {
                    editCard.putExtra(CardEditor.EXTRA_CARD_ID, 0);
                }
                startActivityForResult(editCard, REQUEST_MULTIMEDIA_EDIT);
            }
        });
        mFieldsLayoutContainer.addView(label);
        mFieldsLayoutContainer.addView(editline_view);
    }
}
Also used : MultimediaCardEditorActivity(com.ichi2.anki.multimediacard.activity.MultimediaCardEditorActivity) Typeface(android.graphics.Typeface) SharedPreferences(android.content.SharedPreferences) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) ImageButton(android.widget.ImageButton) TextView(android.widget.TextView)

Aggregations

ImageButton (android.widget.ImageButton)158 View (android.view.View)112 TextView (android.widget.TextView)87 ImageView (android.widget.ImageView)55 Button (android.widget.Button)27 ListView (android.widget.ListView)25 AdapterView (android.widget.AdapterView)24 OnClickListener (android.view.View.OnClickListener)21 LinearLayout (android.widget.LinearLayout)21 Intent (android.content.Intent)19 RelativeLayout (android.widget.RelativeLayout)13 DialogInterface (android.content.DialogInterface)12 Bundle (android.os.Bundle)11 LayoutInflater (android.view.LayoutInflater)11 EditText (android.widget.EditText)11 ViewGroup (android.view.ViewGroup)10 ArrayList (java.util.ArrayList)10 Builder (android.app.AlertDialog.Builder)7 Drawable (android.graphics.drawable.Drawable)7 RecyclerView (android.support.v7.widget.RecyclerView)7