예제 #1
1
 private void initializeView(String input) {
   if (input == null) {
     input = GlowPadView.DEFAULT_TARGETS;
   }
   mTargetStore.clear();
   final int maxTargets =
       mIsScreenLarge ? GlowPadView.MAX_TABLET_TARGETS : GlowPadView.MAX_PHONE_TARGETS;
   final PackageManager packMan = mActivity.getPackageManager();
   final Drawable activeBack =
       mResources.getDrawable(com.android.internal.R.drawable.ic_lockscreen_target_activated);
   final String[] targetStore = input.split("\\|");
   // Shift by 2 targets for phones in landscape
   if (mIsLandscape && !mIsScreenLarge) {
     mTargetStore.add(new TargetInfo(null));
     mTargetStore.add(new TargetInfo(null));
   }
   // Add the unlock icon
   Drawable unlockFront =
       mResources.getDrawable(com.android.internal.R.drawable.ic_lockscreen_unlock_normal);
   Drawable unlockBack =
       mResources.getDrawable(com.android.internal.R.drawable.ic_lockscreen_unlock_activated);
   mTargetStore.add(new TargetInfo(getLayeredDrawable(unlockBack, unlockFront, 0, true)));
   for (int cc = 0; cc < 8 - mTargetOffset - 1; cc++) {
     String uri = GlowPadView.EMPTY_TARGET;
     Drawable front = null;
     Drawable back = activeBack;
     boolean frontBlank = false;
     String iconType = null;
     String iconSource = null;
     int tmpInset = mTargetInset;
     if (cc < targetStore.length && cc < maxTargets) {
       uri = targetStore[cc];
       if (!uri.equals(GlowPadView.EMPTY_TARGET)) {
         try {
           Intent in = Intent.parseUri(uri, 0);
           if (in.hasExtra(GlowPadView.ICON_FILE)) {
             String rSource = in.getStringExtra(GlowPadView.ICON_FILE);
             File fPath = new File(rSource);
             if (fPath != null) {
               if (fPath.exists()) {
                 front = new BitmapDrawable(getResources(), BitmapFactory.decodeFile(rSource));
               }
             }
           } else if (in.hasExtra(GlowPadView.ICON_RESOURCE)) {
             String rSource = in.getStringExtra(GlowPadView.ICON_RESOURCE);
             String rPackage = in.getStringExtra(GlowPadView.ICON_PACKAGE);
             if (rSource != null) {
               if (rPackage != null) {
                 try {
                   Context rContext = mActivity.createPackageContext(rPackage, 0);
                   int id = rContext.getResources().getIdentifier(rSource, "drawable", rPackage);
                   front = rContext.getResources().getDrawable(id);
                   id =
                       rContext
                           .getResources()
                           .getIdentifier(
                               rSource.replaceAll("_normal", "_activated"), "drawable", rPackage);
                   back = rContext.getResources().getDrawable(id);
                   tmpInset = 0;
                   frontBlank = true;
                 } catch (NameNotFoundException e) {
                   e.printStackTrace();
                 } catch (NotFoundException e) {
                   e.printStackTrace();
                 }
               } else {
                 front =
                     mResources.getDrawable(
                         mResources.getIdentifier(rSource, "drawable", "android"));
                 back =
                     mResources.getDrawable(
                         mResources.getIdentifier(
                             rSource.replaceAll("_normal", "_activated"), "drawable", "android"));
                 tmpInset = 0;
                 frontBlank = true;
               }
             }
           }
           if (front == null) {
             ActivityInfo aInfo = in.resolveActivityInfo(packMan, PackageManager.GET_ACTIVITIES);
             if (aInfo != null) {
               front = aInfo.loadIcon(packMan);
             } else {
               front = mResources.getDrawable(android.R.drawable.sym_def_app_icon).mutate();
             }
           }
         } catch (Exception e) {
         }
       }
     } else if (cc >= maxTargets) {
       mTargetStore.add(new TargetInfo(null));
       continue;
     }
     if (back == null || front == null) {
       Drawable emptyIcon = mResources.getDrawable(R.drawable.ic_empty).mutate();
       front = emptyIcon;
     }
     mTargetStore.add(
         new TargetInfo(
             uri,
             getLayeredDrawable(back, front, tmpInset, frontBlank),
             iconType,
             iconSource,
             front.getConstantState().newDrawable().mutate()));
   }
   ArrayList<TargetDrawable> tDraw = new ArrayList<TargetDrawable>();
   for (TargetInfo i : mTargetStore) {
     if (i != null) {
       tDraw.add(new TargetDrawable(mResources, i.icon));
     } else {
       tDraw.add(new TargetDrawable(mResources, null));
     }
   }
   mWaveView.setTargetResources(tDraw);
 }
예제 #2
0
  public void updateResources() {
    // Update the search icon with drawable from the search .apk
    if (!mSearchDisabled) {
      Intent intent =
          ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE))
              .getAssistIntent(mContext, UserHandle.USER_CURRENT);
      if (intent != null) {
        // XXX Hack. We need to substitute the icon here but haven't formalized
        // the public API. The "_google" metadata will be going away, so
        // DON'T USE IT!
        ComponentName component = intent.getComponent();
        boolean replaced =
            mGlowPadView.replaceTargetDrawablesIfPresent(
                component,
                ASSIST_ICON_METADATA_NAME + "_google",
                com.android.internal.R.drawable.ic_action_assist_generic);

        if (!replaced
            && !mGlowPadView.replaceTargetDrawablesIfPresent(
                component,
                ASSIST_ICON_METADATA_NAME,
                com.android.internal.R.drawable.ic_action_assist_generic)) {
          Slog.w(TAG, "Couldn't grab icon from package " + component);
        }
      }
    }

    mGlowPadView.setEnableTarget(
        com.android.internal.R.drawable.ic_lockscreen_camera, !mCameraDisabled);
    mGlowPadView.setEnableTarget(
        com.android.internal.R.drawable.ic_action_assist_generic, !mSearchDisabled);
  }
예제 #3
0
        public void onTrigger(View v, int target) {
          final int resId = mGlowPadView.getResourceIdForTarget(target);
          switch (resId) {
            case com.android.internal.R.drawable.ic_action_assist_generic:
              Intent assistIntent =
                  ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE))
                      .getAssistIntent(mContext, UserHandle.USER_CURRENT);
              if (assistIntent != null) {
                mActivityLauncher.launchActivity(assistIntent, false, true, null, null);
              } else {
                Log.w(TAG, "Failed to get intent for assist activity");
              }
              mCallback.userActivity(0);
              break;

            case com.android.internal.R.drawable.ic_lockscreen_camera:
              mActivityLauncher.launchCamera(null, null);
              mCallback.userActivity(0);
              break;

            case com.android.internal.R.drawable.ic_lockscreen_unlock_phantom:
            case com.android.internal.R.drawable.ic_lockscreen_unlock:
              mCallback.userActivity(0);
              mCallback.dismiss(false);
              break;
          }
        }
예제 #4
0
 @Override
 public void onActivityCreated(Bundle savedInstanceState) {
   super.onActivityCreated(savedInstanceState);
   mWaveView = ((GlowPadView) mActivity.findViewById(R.id.lock_target));
   mWaveView.setOnTriggerListener(this);
   initializeView(
       Settings.System.getString(
           mActivity.getContentResolver(), Settings.System.LOCKSCREEN_TARGETS));
 }
예제 #5
0
  @Override
  protected void onFinishInflate() {
    super.onFinishInflate();
    mGlowPadView = (GlowPadView) findViewById(R.id.glow_pad_view);
    mGlowPadView.setOnTriggerListener(mOnTriggerListener);
    updateTargets();

    mSecurityMessageDisplay = new KeyguardMessageArea.Helper(this);
    View bouncerFrameView = findViewById(R.id.keyguard_selector_view_frame);
    mBouncerFrame = bouncerFrameView.getBackground();
  }
  @Override
  protected void onFinishInflate() {
    super.onFinishInflate();
    mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mSearchTargetsContainer = findViewById(R.id.search_panel_container);
    mStatusBarTouchProxy = (StatusBarTouchProxy) findViewById(R.id.status_bar_touch_proxy);
    // TODO: fetch views
    mGlowPadView = (GlowPadView) findViewById(R.id.glow_pad_view);
    mGlowPadView.setOnTriggerListener(mGlowPadViewListener);

    setDrawables();
  }
 private void maybeSwapSearchIcon() {
   Intent intent = SearchManager.getAssistIntent(mContext);
   if (intent != null) {
     ComponentName component = intent.getComponent();
     if (component == null
         || !mGlowPadView.replaceTargetDrawablesIfPresent(
             component,
             ASSIST_ICON_METADATA_NAME,
             com.android.internal.R.drawable.ic_action_assist_generic)) {
       if (DEBUG) Slog.v(TAG, "Couldn't grab icon for component " + component);
     }
   }
 }
 public void show(final boolean show, boolean animate) {
   if (!show) {
     final LayoutTransition transitioner = animate ? createLayoutTransitioner() : null;
     ((ViewGroup) mSearchTargetsContainer).setLayoutTransition(transitioner);
   }
   mShowing = show;
   if (show) {
     maybeSwapSearchIcon();
     if (getVisibility() != View.VISIBLE) {
       setVisibility(View.VISIBLE);
       // Don't start the animation until we've created the layer, which is done
       // right before we are drawn
       mGlowPadView.suspendAnimations();
       mGlowPadView.ping();
       getViewTreeObserver().addOnPreDrawListener(mPreDrawListener);
       vibrate();
     }
     setFocusable(true);
     setFocusableInTouchMode(true);
     requestFocus();
   } else {
     setVisibility(View.INVISIBLE);
   }
 }
예제 #9
0
 @Override
 public void reset() {
   mGlowPadView.reset(false);
 }
예제 #10
0
 @Override
 public void showUsabilityHint() {
   mGlowPadView.ping();
 }
예제 #11
0
 public boolean isTargetPresent(int resId) {
   return mGlowPadView.getTargetPosition(resId) != -1;
 }
 public boolean onPreDraw() {
   getViewTreeObserver().removeOnPreDrawListener(this);
   mGlowPadView.resumeAnimations();
   return false;
 }
  private void setDrawables() {
    String target3 =
        Settings.System.getString(
            mContext.getContentResolver(), Settings.System.SYSTEMUI_NAVRING_3);
    if (target3 == null || target3.equals("")) {
      Settings.System.putString(
          mContext.getContentResolver(), Settings.System.SYSTEMUI_NAVRING_3, "assist");
    }

    // Custom Targets
    ArrayList<TargetDrawable> storedDraw = new ArrayList<TargetDrawable>();

    int startPosOffset;
    int endPosOffset;

    if (screenLayout() == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
      startPosOffset = 1;
      endPosOffset = 8;
    } else if (screenLayout() == Configuration.SCREENLAYOUT_SIZE_LARGE) {
      if (mNavRingAmount == 4 || mNavRingAmount == 2) {
        startPosOffset = 0;
        endPosOffset = 1;
      } else {
        startPosOffset = 0;
        endPosOffset = 3;
      }
    } else {
      if (isScreenPortrait() == true) {
        if (mNavRingAmount == 4 || mNavRingAmount == 2) {
          startPosOffset = 0;
          endPosOffset = 1;
        } else {
          startPosOffset = 0;
          endPosOffset = 3;
        }
      } else {
        if (mNavRingAmount == 4 || mNavRingAmount == 2) {
          startPosOffset = 2;
          endPosOffset = 0;
        } else {
          startPosOffset = 2;
          endPosOffset = 1;
        }
      }
    }

    List<String> targetActivities =
        Arrays.asList(
            Settings.System.getString(mContext.getContentResolver(), targetList.get(0)),
            Settings.System.getString(mContext.getContentResolver(), targetList.get(1)),
            Settings.System.getString(mContext.getContentResolver(), targetList.get(2)),
            Settings.System.getString(mContext.getContentResolver(), targetList.get(3)),
            Settings.System.getString(mContext.getContentResolver(), targetList.get(4)));

    // Place Holder Targets
    TargetDrawable cDrawable =
        new TargetDrawable(
            mResources,
            mResources.getDrawable(com.android.internal.R.drawable.ic_lockscreen_camera));
    cDrawable.setEnabled(false);

    // Add Initial Place Holder Targets
    for (int i = 0; i < startPosOffset; i++) {
      storedDraw.add(cDrawable);
    }

    // Add User Targets
    for (int i = 0; i < targetActivities.size(); i++)
      if (targetActivities.get(i) == null
          || targetActivities.get(i).equals("")
          || targetActivities.get(i).equals("none")) {
        storedDraw.add(cDrawable);
      } else if (targetActivities.get(i).equals("screenshot")) {
        storedDraw.add(
            new TargetDrawable(
                mResources, mResources.getDrawable(R.drawable.ic_navbar_screenshot)));
      } else if (targetActivities.get(i).equals("ime_switcher")) {
        storedDraw.add(
            new TargetDrawable(
                mResources, mResources.getDrawable(R.drawable.ic_sysbar_ime_switcher)));
      } else if (targetActivities.get(i).equals("ring_vib")) {
        storedDraw.add(
            new TargetDrawable(mResources, mResources.getDrawable(R.drawable.ic_navbar_vib)));
      } else if (targetActivities.get(i).equals("ring_silent")) {
        storedDraw.add(
            new TargetDrawable(mResources, mResources.getDrawable(R.drawable.ic_navbar_silent)));
      } else if (targetActivities.get(i).equals("ring_vib_silent")) {
        storedDraw.add(
            new TargetDrawable(
                mResources, mResources.getDrawable(R.drawable.ic_navbar_ring_vib_silent)));
      } else if (targetActivities.get(i).equals("killcurrent")) {
        storedDraw.add(
            new TargetDrawable(mResources, mResources.getDrawable(R.drawable.ic_navbar_killtask)));
      } else if (targetActivities.get(i).equals("power")) {
        storedDraw.add(
            new TargetDrawable(mResources, mResources.getDrawable(R.drawable.ic_navbar_power)));
      } else if (targetActivities.get(i).equals("screenoff")) {
        storedDraw.add(
            new TargetDrawable(mResources, mResources.getDrawable(R.drawable.ic_navbar_power)));
      } else if (targetActivities.get(i).equals("assist")) {
        storedDraw.add(
            new TargetDrawable(
                mResources, com.android.internal.R.drawable.ic_action_assist_generic));
      } else if (targetActivities.get(i).startsWith("app:")) {
        try {
          ActivityInfo activityInfo =
              mPackageManager.getActivityInfo(
                  ComponentName.unflattenFromString(targetActivities.get(i).substring(4)),
                  PackageManager.GET_RECEIVERS);
          Drawable activityIcon = activityInfo.loadIcon(mPackageManager);

          storedDraw.add(new TargetDrawable(mResources, activityIcon));
        } catch (Exception e) { // /
        }
      }

    // Add End Place Holder Targets
    for (int i = 0; i < endPosOffset; i++) {
      storedDraw.add(cDrawable);
    }

    mGlowPadView.setTargetResources(storedDraw);
  }