Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.

Small fixes and test #189

Merged
merged 9 commits into from
Mar 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions constraintlayout/.idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,18 @@
android:configChanges="orientation|screenSize"/>
<activity android:name=".RotationAngular"
android:configChanges="orientation|screenSize"/>
<activity android:name=".CustomSwipeClick" />
<activity android:name=".CustomSwipeClick" />
<activity android:name=".RotationToolbar"
android:label="To Run Disable Animation"
android:configChanges="orientation|screenSize"/>
<activity android:name=".RotationRotateToToolbar"
android:label="To Run Disable Animation"
android:configChanges="orientation|screenSize"/>
<activity android:name=".ConstraintSetVerify"
android:label="Test ConstraintSet on ConstraintLayout"
/>
<activity android:name=".CheckCallbackActivity" />

</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package android.support.constraint.app;

import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.motion.widget.Debug;
import androidx.constraintlayout.motion.widget.MotionLayout;
import androidx.constraintlayout.motion.widget.TransitionAdapter;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

// used with verification_042.xml
public class CheckCallbackActivity extends AppCompatActivity {
private static final String TAG = "CustomSwipeClick";
String layout_name;
MotionLayout mMotionLayout;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle extra = getIntent().getExtras();
String prelayout = extra.getString(Utils.KEY);
setTitle(layout_name = prelayout);
Context ctx = getApplicationContext();
int id = ctx.getResources().getIdentifier(prelayout, "layout", ctx.getPackageName());
setContentView(id);
mMotionLayout = Utils.findMotionLayout(this);

populateRecyclerView();

TextView text = findViewById(R.id.text);
if (text != null) {
mMotionLayout.setTransitionListener(new TransitionAdapter() {
@Override
public void onTransitionCompleted(MotionLayout motionLayout, int currentId) {
text.setText((currentId == R.id.expanded) ? "cb down" : "cb up");
Log.v(TAG, Debug.getLoc() + " "+Debug.getName(getApplicationContext(),currentId));
}

});
}
}
// ================================= Recycler support ====================================
private void populateRecyclerView() {
RecyclerView rview = Utils.findView(this, RecyclerView.class);
if (rview == null) {
return;
}

rview.setLayoutManager(new LinearLayoutManager(this));
rview.setAdapter(new MyAdapter());
}

static class MyAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private String[] mDataset = new String[300];
{
for (int i = 0; i < mDataset.length; i++) {
mDataset[i] = "hello world 1234567890 ".substring(0,12+(i%10));
}
}

@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
TextView tv = new TextView(parent.getContext());
tv.setPadding(10, 10, 10, 5);
tv.setTextSize(30);
RecyclerView.ViewHolder vh = new RecyclerView.ViewHolder(tv){};
return vh;
}

@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
((TextView)holder.itemView).setText(mDataset[position]);
}

@Override
public int getItemCount() {
return mDataset.length;
}
}



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package android.support.constraint.app;

import android.content.Context;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.ConstraintSet;

public class ConstraintSetVerify extends AppCompatActivity {
private static final String TAG = "ConstraintSetVerify";
String layout_name;
ConstraintLayout mConstraintLayout;

@Override
protected void onCreate(@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle extra = getIntent().getExtras();
String prelayout = extra.getString(Utils.KEY);
layout_name = prelayout;
Context ctx = getApplicationContext();
int id = ctx.getResources().getIdentifier(prelayout, "layout", ctx.getPackageName());
ActionBar bar = getSupportActionBar();
if (bar != null) {
bar.hide();
}
setContentView(id);
mConstraintLayout = Utils.findConstraintLayout(this);
findViewById(R.id.showContent).setOnClickListener( (v)->showContent(v));
findViewById(R.id.showSplash).setOnClickListener( (v)->showSplash(v));
}
public void showSplash(View v) {
ConstraintSet set = new ConstraintSet();
set.clone(mConstraintLayout);
set.setVerticalBias(R.id.logo, 0.5f);
set.setVisibility(R.id.splashScreen, View.VISIBLE);
set.setVisibility(R.id.contentGroup, View.GONE);
set.applyTo(mConstraintLayout);
}
public void showContent(View v) {

ConstraintSet set = new ConstraintSet();
set.clone(mConstraintLayout);
set.setVerticalBias(R.id.logo, 0.3f);
set.setVisibility(R.id.splashScreen, View.GONE);
set.setVisibility(R.id.contentGroup, View.VISIBLE);
set.applyTo(mConstraintLayout);

}

}
Loading